Mercurial > vim
annotate src/term.c @ 34541:a4b8338f9e76
Added tag v9.1.0172 for changeset 9e093c96dff6a77b52d783dfe28f47b70e7fa33a
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Tue, 12 Mar 2024 22:00:06 +0100 |
parents | 737023edd0a5 |
children | 286bee19bc96 |
rev | line source |
---|---|
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1 /* vi:set ts=8 sts=4 sw=4 noet: |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2 * |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3 * VIM - Vi IMproved by Bram Moolenaar |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4 * |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5 * Do ":help uganda" in Vim to read copying and usage conditions. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6 * Do ":help credits" in Vim to see a list of people who contributed. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7 * See README.txt for an overview of the Vim source code. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
8 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
9 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
10 * |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
11 * term.c: functions for controlling the terminal |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
12 * |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
13 * primitive termcap support for Amiga and Win32 included |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
14 * |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
15 * NOTE: padding and variable substitution is not performed, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
16 * when compiling without HAVE_TGETENT, we use tputs() and tgoto() dummies. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
17 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
18 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
19 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
20 * Some systems have a prototype for tgetstr() with (char *) instead of |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
21 * (char **). This define removes that prototype. We include our own prototype |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
22 * below. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
23 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
24 #define tgetstr tgetstr_defined_wrong |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
25 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
26 #include "vim.h" |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
27 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
28 #ifdef HAVE_TGETENT |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
29 # ifdef HAVE_TERMIOS_H |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
30 # include <termios.h> // seems to be required for some Linux |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
31 # endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
32 # ifdef HAVE_TERMCAP_H |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
33 # include <termcap.h> |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
34 # endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
35 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
36 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
37 * A few linux systems define outfuntype in termcap.h to be used as the third |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
38 * argument for tputs(). |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
39 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
40 # if defined(VMS) || defined(AMIGA) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
41 # define TPUTSFUNCAST (void (*)(unsigned int)) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
42 # else |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
43 # ifdef HAVE_OUTFUNTYPE |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
44 # define TPUTSFUNCAST (outfuntype) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
45 # else |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
46 # define TPUTSFUNCAST (int (*)(int)) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
47 # endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
48 # endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
49 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
50 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
51 #undef tgetstr |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
52 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
53 // start of keys that are not directly used by Vim but can be mapped |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
54 #define BT_EXTRA_KEYS 0x101 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
55 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
56 static void parse_builtin_tcap(char_u *s); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
57 static void gather_termleader(void); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
58 #ifdef FEAT_TERMRESPONSE |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
59 static void req_codes_from_term(void); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
60 static void req_more_codes_from_term(void); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
61 static void got_code_from_term(char_u *code, int len); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
62 static void check_for_codes_from_term(void); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
63 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
64 static void del_termcode_idx(int idx); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
65 static int find_term_bykeys(char_u *src); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
66 static int term_is_builtin(char_u *name); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
67 static int term_7to8bit(char_u *p); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
68 static void accept_modifiers_for_function_keys(void); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
69 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
70 // Change this to "if 1" to debug what happens with termresponse. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
71 # if 0 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
72 # define DEBUG_TERMRESPONSE |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
73 static void log_tr(const char *fmt, ...) ATTRIBUTE_FORMAT_PRINTF(1, 2); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
74 # define LOG_TR(msg) log_tr msg |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
75 # else |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
76 # define LOG_TR(msg) do { /**/ } while (0) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
77 # endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
78 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
79 #ifdef HAVE_TGETENT |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
80 static char *invoke_tgetent(char_u *, char_u *); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
81 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
82 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
83 * Here is our own prototype for tgetstr(), any prototypes from the include |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
84 * files have been disabled by the define at the start of this file. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
85 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
86 char *tgetstr(char *, char **); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
87 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
88 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
89 typedef enum { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
90 STATUS_GET, // send request when switching to RAW mode |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
91 STATUS_SENT, // did send request, checking for response |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
92 STATUS_GOT, // received response |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
93 STATUS_FAIL // timed out |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
94 } request_progress_T; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
95 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
96 typedef struct { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
97 request_progress_T tr_progress; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
98 time_t tr_start; // when request was sent, -1 for never |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
99 } termrequest_T; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
100 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
101 # define TERMREQUEST_INIT {STATUS_GET, -1} |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
102 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
103 // Request Terminal Version status: |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
104 static termrequest_T crv_status = TERMREQUEST_INIT; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
105 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
106 // Request Cursor position report: |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
107 static termrequest_T u7_status = TERMREQUEST_INIT; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
108 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
109 // Request xterm compatibility check: |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
110 static termrequest_T xcc_status = TERMREQUEST_INIT; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
111 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
112 #ifdef FEAT_TERMRESPONSE |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
113 # ifdef FEAT_TERMINAL |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
114 // Request foreground color report: |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
115 static termrequest_T rfg_status = TERMREQUEST_INIT; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
116 static int fg_r = 0; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
117 static int fg_g = 0; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
118 static int fg_b = 0; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
119 static int bg_r = 255; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
120 static int bg_g = 255; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
121 static int bg_b = 255; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
122 # endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
123 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
124 // Request background color report: |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
125 static termrequest_T rbg_status = TERMREQUEST_INIT; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
126 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
127 // Request cursor blinking mode report: |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
128 static termrequest_T rbm_status = TERMREQUEST_INIT; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
129 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
130 // Request cursor style report: |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
131 static termrequest_T rcs_status = TERMREQUEST_INIT; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
132 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
133 // Request window's position report: |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
134 static termrequest_T winpos_status = TERMREQUEST_INIT; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
135 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
136 static termrequest_T *all_termrequests[] = { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
137 &crv_status, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
138 &u7_status, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
139 &xcc_status, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
140 # ifdef FEAT_TERMINAL |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
141 &rfg_status, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
142 # endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
143 &rbg_status, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
144 &rbm_status, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
145 &rcs_status, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
146 &winpos_status, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
147 NULL |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
148 }; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
149 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
150 // The t_8u code may default to a value but get reset when the term response is |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
151 // received. To avoid redrawing too often, only redraw when t_8u is not reset |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
152 // and it was supposed to be written. Unless t_8u was set explicitly. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
153 // FALSE -> don't output t_8u yet |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
154 // MAYBE -> tried outputting t_8u while FALSE |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
155 // OK -> can write t_8u |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
156 int write_t_8u_state = FALSE; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
157 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
158 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
159 #ifdef HAVE_TGETENT |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
160 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
161 * Don't declare these variables if termcap.h contains them. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
162 * Autoconf checks if these variables should be declared extern (not all |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
163 * systems have them). |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
164 * Some versions define ospeed to be speed_t, but that is incompatible with |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
165 * BSD, where ospeed is short and speed_t is long. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
166 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
167 # ifndef HAVE_OSPEED |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
168 # ifdef OSPEED_EXTERN |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
169 extern short ospeed; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
170 # else |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
171 short ospeed; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
172 # endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
173 # endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
174 # ifndef HAVE_UP_BC_PC |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
175 # ifdef UP_BC_PC_EXTERN |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
176 extern char *UP, *BC, PC; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
177 # else |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
178 char *UP, *BC, PC; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
179 # endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
180 # endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
181 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
182 # define TGETSTR(s, p) vim_tgetstr((s), (p)) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
183 # define TGETENT(b, t) tgetent((char *)(b), (char *)(t)) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
184 static char_u *vim_tgetstr(char *s, char_u **pp); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
185 #endif // HAVE_TGETENT |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
186 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
187 static int detected_8bit = FALSE; // detected 8-bit terminal |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
188 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
189 #if (defined(UNIX) || defined(VMS)) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
190 static int focus_state = MAYBE; // TRUE if the Vim window has focus |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
191 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
192 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
193 #ifdef FEAT_TERMRESPONSE |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
194 // When the cursor shape was detected these values are used: |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
195 // 1: block, 2: underline, 3: vertical bar |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
196 static int initial_cursor_shape = 0; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
197 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
198 // The blink flag from the style response may be inverted from the actual |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
199 // blinking state, xterm XORs the flags. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
200 static int initial_cursor_shape_blink = FALSE; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
201 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
202 // The blink flag from the blinking-cursor mode response |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
203 static int initial_cursor_blink = FALSE; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
204 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
205 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
206 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
207 * The builtin termcap entries. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
208 * |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
209 * The entries are also included when HAVE_TGETENT is defined, the system |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
210 * termcap may be incomplete and a few Vim-specific entries are added. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
211 * |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
212 * When HAVE_TGETENT is defined, the builtin entries can be accessed with |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
213 * "builtin_amiga", "builtin_ansi", "builtin_debug", etc. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
214 * |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
215 * Each termcap is a list of tcap_entry_T. See parse_builtin_tcap() for all |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
216 * details. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
217 * |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
218 * Entries marked with "guessed" may be wrong. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
219 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
220 typedef struct |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
221 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
222 int bt_entry; // either a KS_xxx code (>= 0), or a K_xxx code. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
223 char *bt_string; // value |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
224 } tcap_entry_T; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
225 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
226 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
227 * Standard ANSI terminal, default for Unix. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
228 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
229 static tcap_entry_T builtin_ansi[] = { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
230 {(int)KS_CE, "\033[K"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
231 {(int)KS_AL, "\033[L"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
232 # ifdef TERMINFO |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
233 {(int)KS_CAL, "\033[%p1%dL"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
234 # else |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
235 {(int)KS_CAL, "\033[%dL"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
236 # endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
237 {(int)KS_DL, "\033[M"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
238 # ifdef TERMINFO |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
239 {(int)KS_CDL, "\033[%p1%dM"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
240 # else |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
241 {(int)KS_CDL, "\033[%dM"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
242 # endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
243 {(int)KS_CL, "\033[H\033[2J"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
244 {(int)KS_ME, "\033[0m"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
245 {(int)KS_MR, "\033[7m"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
246 {(int)KS_MS, "y"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
247 {(int)KS_UT, "y"}, // guessed |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
248 {(int)KS_LE, "\b"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
249 # ifdef TERMINFO |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
250 {(int)KS_CM, "\033[%i%p1%d;%p2%dH"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
251 # else |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
252 {(int)KS_CM, "\033[%i%d;%dH"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
253 # endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
254 # ifdef TERMINFO |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
255 {(int)KS_CRI, "\033[%p1%dC"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
256 # else |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
257 {(int)KS_CRI, "\033[%dC"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
258 # endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
259 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
260 {(int)KS_NAME, NULL} // end marker |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
261 }; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
262 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
263 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
264 * VT320 is working as an ANSI terminal compatible DEC terminal. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
265 * (it covers VT1x0, VT2x0 and VT3x0 up to VT320 on VMS as well) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
266 * TODO:- rewrite ESC[ codes to CSI |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
267 * - keyboard languages (CSI ? 26 n) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
268 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
269 static tcap_entry_T builtin_vt320[] = { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
270 {(int)KS_CE, "\033[K"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
271 {(int)KS_AL, "\033[L"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
272 # ifdef TERMINFO |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
273 {(int)KS_CAL, "\033[%p1%dL"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
274 # else |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
275 {(int)KS_CAL, "\033[%dL"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
276 # endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
277 {(int)KS_DL, "\033[M"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
278 # ifdef TERMINFO |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
279 {(int)KS_CDL, "\033[%p1%dM"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
280 # else |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
281 {(int)KS_CDL, "\033[%dM"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
282 # endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
283 {(int)KS_CL, "\033[H\033[2J"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
284 {(int)KS_CD, "\033[J"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
285 {(int)KS_CCO, "8"}, // allow 8 colors |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
286 {(int)KS_ME, "\033[0m"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
287 {(int)KS_MR, "\033[7m"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
288 {(int)KS_MD, "\033[1m"}, // bold mode |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
289 {(int)KS_SE, "\033[22m"},// normal mode |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
290 {(int)KS_UE, "\033[24m"},// exit underscore mode |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
291 {(int)KS_US, "\033[4m"}, // underscore mode |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
292 {(int)KS_CZH, "\033[34;43m"}, // italic mode: blue text on yellow |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
293 {(int)KS_CZR, "\033[0m"}, // italic mode end |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
294 {(int)KS_CAB, "\033[4%dm"}, // set background color (ANSI) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
295 {(int)KS_CAF, "\033[3%dm"}, // set foreground color (ANSI) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
296 {(int)KS_CSB, "\033[102;%dm"}, // set screen background color |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
297 {(int)KS_CSF, "\033[101;%dm"}, // set screen foreground color |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
298 {(int)KS_MS, "y"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
299 {(int)KS_UT, "y"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
300 {(int)KS_XN, "y"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
301 {(int)KS_LE, "\b"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
302 # ifdef TERMINFO |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
303 {(int)KS_CM, "\033[%i%p1%d;%p2%dH"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
304 # else |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
305 {(int)KS_CM, "\033[%i%d;%dH"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
306 # endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
307 # ifdef TERMINFO |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
308 {(int)KS_CRI, "\033[%p1%dC"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
309 # else |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
310 {(int)KS_CRI, "\033[%dC"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
311 # endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
312 {K_UP, "\033[A"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
313 {K_DOWN, "\033[B"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
314 {K_RIGHT, "\033[C"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
315 {K_LEFT, "\033[D"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
316 // Note: cursor key sequences for application cursor mode are omitted, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
317 // because they interfere with typed commands: <Esc>OA. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
318 {K_F1, "\033[11~"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
319 {K_F2, "\033[12~"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
320 {K_F3, "\033[13~"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
321 {K_F4, "\033[14~"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
322 {K_F5, "\033[15~"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
323 {K_F6, "\033[17~"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
324 {K_F7, "\033[18~"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
325 {K_F8, "\033[19~"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
326 {K_F9, "\033[20~"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
327 {K_F10, "\033[21~"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
328 {K_F11, "\033[23~"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
329 {K_F12, "\033[24~"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
330 {K_F13, "\033[25~"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
331 {K_F14, "\033[26~"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
332 {K_F15, "\033[28~"}, // Help |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
333 {K_F16, "\033[29~"}, // Select |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
334 {K_F17, "\033[31~"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
335 {K_F18, "\033[32~"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
336 {K_F19, "\033[33~"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
337 {K_F20, "\033[34~"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
338 {K_INS, "\033[2~"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
339 {K_DEL, "\033[3~"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
340 {K_HOME, "\033[1~"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
341 {K_END, "\033[4~"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
342 {K_PAGEUP, "\033[5~"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
343 {K_PAGEDOWN, "\033[6~"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
344 // These sequences starting with <Esc> O may interfere with what the user |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
345 // is typing. Remove these if that bothers you. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
346 {K_KPLUS, "\033Ok"}, // keypad plus |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
347 {K_KMINUS, "\033Om"}, // keypad minus |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
348 {K_KDIVIDE, "\033Oo"}, // keypad / |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
349 {K_KMULTIPLY, "\033Oj"}, // keypad * |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
350 {K_KENTER, "\033OM"}, // keypad Enter |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
351 {K_K0, "\033Op"}, // keypad 0 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
352 {K_K1, "\033Oq"}, // keypad 1 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
353 {K_K2, "\033Or"}, // keypad 2 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
354 {K_K3, "\033Os"}, // keypad 3 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
355 {K_K4, "\033Ot"}, // keypad 4 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
356 {K_K5, "\033Ou"}, // keypad 5 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
357 {K_K6, "\033Ov"}, // keypad 6 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
358 {K_K7, "\033Ow"}, // keypad 7 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
359 {K_K8, "\033Ox"}, // keypad 8 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
360 {K_K9, "\033Oy"}, // keypad 9 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
361 {K_BS, "\x7f"}, // for some reason 0177 doesn't work |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
362 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
363 {(int)KS_NAME, NULL} // end marker |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
364 }; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
365 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
366 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
367 * Ordinary vt52 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
368 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
369 static tcap_entry_T builtin_vt52[] = { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
370 {(int)KS_CE, "\033K"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
371 {(int)KS_CD, "\033J"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
372 # ifdef TERMINFO |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
373 {(int)KS_CM, "\033Y%p1%' '%+%c%p2%' '%+%c"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
374 # else |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
375 {(int)KS_CM, "\033Y%+ %+ "}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
376 # endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
377 {(int)KS_LE, "\b"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
378 {(int)KS_SR, "\033I"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
379 {(int)KS_AL, "\033L"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
380 {(int)KS_DL, "\033M"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
381 {K_UP, "\033A"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
382 {K_DOWN, "\033B"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
383 {K_LEFT, "\033D"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
384 {K_RIGHT, "\033C"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
385 {K_F1, "\033P"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
386 {K_F2, "\033Q"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
387 {K_F3, "\033R"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
388 {(int)KS_CL, "\033H\033J"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
389 {(int)KS_MS, "y"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
390 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
391 {(int)KS_NAME, NULL} // end marker |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
392 }; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
393 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
394 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
395 * Builtin xterm with Vim-specific entries. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
396 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
397 static tcap_entry_T builtin_xterm[] = { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
398 {(int)KS_CE, "\033[K"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
399 {(int)KS_AL, "\033[L"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
400 # ifdef TERMINFO |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
401 {(int)KS_CAL, "\033[%p1%dL"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
402 # else |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
403 {(int)KS_CAL, "\033[%dL"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
404 # endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
405 {(int)KS_DL, "\033[M"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
406 # ifdef TERMINFO |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
407 {(int)KS_CDL, "\033[%p1%dM"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
408 # else |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
409 {(int)KS_CDL, "\033[%dM"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
410 # endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
411 # ifdef TERMINFO |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
412 {(int)KS_CS, "\033[%i%p1%d;%p2%dr"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
413 # else |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
414 {(int)KS_CS, "\033[%i%d;%dr"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
415 # endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
416 {(int)KS_CL, "\033[H\033[2J"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
417 {(int)KS_CD, "\033[J"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
418 {(int)KS_ME, "\033[m"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
419 {(int)KS_MR, "\033[7m"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
420 {(int)KS_MD, "\033[1m"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
421 {(int)KS_UE, "\033[m"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
422 {(int)KS_US, "\033[4m"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
423 {(int)KS_STE, "\033[29m"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
424 {(int)KS_STS, "\033[9m"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
425 {(int)KS_MS, "y"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
426 {(int)KS_UT, "y"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
427 {(int)KS_LE, "\b"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
428 {(int)KS_VI, "\033[?25l"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
429 {(int)KS_VE, "\033[?25h"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
430 {(int)KS_VS, "\033[?12h"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
431 {(int)KS_CVS, "\033[?12l"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
432 # ifdef TERMINFO |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
433 {(int)KS_CSH, "\033[%p1%d q"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
434 # else |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
435 {(int)KS_CSH, "\033[%d q"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
436 # endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
437 {(int)KS_CRC, "\033[?12$p"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
438 {(int)KS_CRS, "\033P$q q\033\\"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
439 # ifdef TERMINFO |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
440 {(int)KS_CM, "\033[%i%p1%d;%p2%dH"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
441 # else |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
442 {(int)KS_CM, "\033[%i%d;%dH"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
443 # endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
444 {(int)KS_SR, "\033M"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
445 # ifdef TERMINFO |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
446 {(int)KS_CRI, "\033[%p1%dC"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
447 # else |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
448 {(int)KS_CRI, "\033[%dC"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
449 # endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
450 {(int)KS_KS, "\033[?1h\033="}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
451 {(int)KS_KE, "\033[?1l\033>"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
452 # ifdef FEAT_XTERM_SAVE |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
453 {(int)KS_TI, "\0337\033[?47h"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
454 {(int)KS_TE, "\033[?47l\0338"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
455 # endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
456 // These are now under control of the 'keyprotocol' option, see |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
457 // "builtin_mok2". |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
458 // {(int)KS_CTI, "\033[>4;2m"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
459 // {(int)KS_CRK, "\033[?4m"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
460 // {(int)KS_CTE, "\033[>4;m"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
461 {(int)KS_CIS, "\033]1;"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
462 {(int)KS_CIE, "\007"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
463 {(int)KS_TS, "\033]2;"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
464 {(int)KS_FS, "\007"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
465 {(int)KS_CSC, "\033]12;"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
466 {(int)KS_CEC, "\007"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
467 # ifdef TERMINFO |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
468 {(int)KS_CWS, "\033[8;%p1%d;%p2%dt"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
469 {(int)KS_CWP, "\033[3;%p1%d;%p2%dt"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
470 {(int)KS_CGP, "\033[13t"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
471 # else |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
472 {(int)KS_CWS, "\033[8;%d;%dt"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
473 {(int)KS_CWP, "\033[3;%d;%dt"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
474 {(int)KS_CGP, "\033[13t"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
475 # endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
476 {(int)KS_CRV, "\033[>c"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
477 {(int)KS_CXM, "\033[?1006;1000%?%p1%{1}%=%th%el%;"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
478 {(int)KS_RFG, "\033]10;?\007"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
479 {(int)KS_RBG, "\033]11;?\007"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
480 {(int)KS_U7, "\033[6n"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
481 {(int)KS_CAU, "\033[58;5;%dm"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
482 {(int)KS_CBE, "\033[?2004h"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
483 {(int)KS_CBD, "\033[?2004l"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
484 {(int)KS_CST, "\033[22;2t"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
485 {(int)KS_CRT, "\033[23;2t"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
486 {(int)KS_SSI, "\033[22;1t"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
487 {(int)KS_SRI, "\033[23;1t"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
488 # if (defined(UNIX) || defined(VMS)) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
489 {(int)KS_FD, "\033[?1004l"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
490 {(int)KS_FE, "\033[?1004h"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
491 # endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
492 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
493 {K_UP, "\033O*A"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
494 {K_DOWN, "\033O*B"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
495 {K_RIGHT, "\033O*C"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
496 {K_LEFT, "\033O*D"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
497 // An extra set of cursor keys for vt100 mode |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
498 {K_XUP, "\033[@;*A"}, // Esc [ A or Esc [ 1 ; A |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
499 {K_XDOWN, "\033[@;*B"}, // Esc [ B or Esc [ 1 ; B |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
500 {K_XRIGHT, "\033[@;*C"}, // Esc [ C or Esc [ 1 ; C |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
501 {K_XLEFT, "\033[@;*D"}, // Esc [ D or Esc [ 1 ; D |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
502 // An extra set of function keys for vt100 mode |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
503 {K_XF1, "\033O*P"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
504 {K_XF2, "\033O*Q"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
505 {K_XF3, "\033O*R"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
506 {K_XF4, "\033O*S"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
507 {K_F1, "\033[11;*~"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
508 {K_F2, "\033[12;*~"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
509 {K_F3, "\033[13;*~"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
510 {K_F4, "\033[14;*~"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
511 {K_F5, "\033[15;*~"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
512 {K_F6, "\033[17;*~"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
513 {K_F7, "\033[18;*~"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
514 {K_F8, "\033[19;*~"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
515 {K_F9, "\033[20;*~"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
516 {K_F10, "\033[21;*~"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
517 {K_F11, "\033[23;*~"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
518 {K_F12, "\033[24;*~"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
519 {K_S_TAB, "\033[Z"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
520 {K_HELP, "\033[28;*~"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
521 {K_UNDO, "\033[26;*~"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
522 {K_INS, "\033[2;*~"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
523 {K_HOME, "\033[@;*H"}, // Esc [ H or Esc 1 ; H |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
524 // {K_S_HOME, "\033O2H"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
525 // {K_C_HOME, "\033O5H"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
526 {K_KHOME, "\033[1;*~"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
527 {K_XHOME, "\033O*H"}, // other Home |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
528 {K_ZHOME, "\033[7;*~"}, // other Home |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
529 {K_END, "\033[@;*F"}, // Esc [ F or Esc 1 ; F |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
530 // {K_S_END, "\033O2F"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
531 // {K_C_END, "\033O5F"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
532 {K_KEND, "\033[4;*~"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
533 {K_XEND, "\033O*F"}, // other End |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
534 {K_ZEND, "\033[8;*~"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
535 {K_PAGEUP, "\033[5;*~"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
536 {K_PAGEDOWN, "\033[6;*~"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
537 {K_KPLUS, "\033O*k"}, // keypad plus |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
538 {K_KMINUS, "\033O*m"}, // keypad minus |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
539 {K_KDIVIDE, "\033O*o"}, // keypad / |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
540 {K_KMULTIPLY, "\033O*j"}, // keypad * |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
541 {K_KENTER, "\033O*M"}, // keypad Enter |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
542 {K_KPOINT, "\033O*n"}, // keypad . |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
543 {K_K0, "\033O*p"}, // keypad 0 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
544 {K_K1, "\033O*q"}, // keypad 1 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
545 {K_K2, "\033O*r"}, // keypad 2 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
546 {K_K3, "\033O*s"}, // keypad 3 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
547 {K_K4, "\033O*t"}, // keypad 4 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
548 {K_K5, "\033O*u"}, // keypad 5 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
549 {K_K6, "\033O*v"}, // keypad 6 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
550 {K_K7, "\033O*w"}, // keypad 7 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
551 {K_K8, "\033O*x"}, // keypad 8 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
552 {K_K9, "\033O*y"}, // keypad 9 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
553 {K_KDEL, "\033[3;*~"}, // keypad Del |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
554 {K_PS, "\033[200~"}, // paste start |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
555 {K_PE, "\033[201~"}, // paste end |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
556 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
557 {BT_EXTRA_KEYS, ""}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
558 {TERMCAP2KEY('k', '0'), "\033[10;*~"}, // F0 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
559 {TERMCAP2KEY('F', '3'), "\033[25;*~"}, // F13 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
560 // F14 and F15 are missing, because they send the same codes as the undo |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
561 // and help key, although they don't work on all keyboards. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
562 {TERMCAP2KEY('F', '6'), "\033[29;*~"}, // F16 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
563 {TERMCAP2KEY('F', '7'), "\033[31;*~"}, // F17 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
564 {TERMCAP2KEY('F', '8'), "\033[32;*~"}, // F18 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
565 {TERMCAP2KEY('F', '9'), "\033[33;*~"}, // F19 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
566 {TERMCAP2KEY('F', 'A'), "\033[34;*~"}, // F20 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
567 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
568 {TERMCAP2KEY('F', 'B'), "\033[42;*~"}, // F21 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
569 {TERMCAP2KEY('F', 'C'), "\033[43;*~"}, // F22 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
570 {TERMCAP2KEY('F', 'D'), "\033[44;*~"}, // F23 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
571 {TERMCAP2KEY('F', 'E'), "\033[45;*~"}, // F24 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
572 {TERMCAP2KEY('F', 'F'), "\033[46;*~"}, // F25 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
573 {TERMCAP2KEY('F', 'G'), "\033[47;*~"}, // F26 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
574 {TERMCAP2KEY('F', 'H'), "\033[48;*~"}, // F27 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
575 {TERMCAP2KEY('F', 'I'), "\033[49;*~"}, // F28 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
576 {TERMCAP2KEY('F', 'J'), "\033[50;*~"}, // F29 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
577 {TERMCAP2KEY('F', 'K'), "\033[51;*~"}, // F30 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
578 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
579 {TERMCAP2KEY('F', 'L'), "\033[52;*~"}, // F31 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
580 {TERMCAP2KEY('F', 'M'), "\033[53;*~"}, // F32 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
581 {TERMCAP2KEY('F', 'N'), "\033[54;*~"}, // F33 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
582 {TERMCAP2KEY('F', 'O'), "\033[55;*~"}, // F34 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
583 {TERMCAP2KEY('F', 'P'), "\033[56;*~"}, // F35 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
584 {TERMCAP2KEY('F', 'Q'), "\033[57;*~"}, // F36 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
585 {TERMCAP2KEY('F', 'R'), "\033[58;*~"}, // F37 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
586 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
587 {(int)KS_NAME, NULL} // end marker |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
588 }; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
589 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
590 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
591 * Additions for using modifyOtherKeys level 2. Same as what is used for |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
592 * xterm. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
593 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
594 static tcap_entry_T builtin_mok2[] = { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
595 // t_TI enables modifyOtherKeys level 2 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
596 {(int)KS_CTI, "\033[>4;2m"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
597 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
598 // XTQMODKEYS was added in xterm version 377: "CSI ? 4 m" which should |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
599 // return "{lead} > 4 ; Pv m". Before version 377 we expect it to have no |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
600 // effect. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
601 {(int)KS_CRK, "\033[?4m"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
602 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
603 // t_TE disables modifyOtherKeys |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
604 {(int)KS_CTE, "\033[>4;m"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
605 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
606 {(int)KS_NAME, NULL} // end marker |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
607 }; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
608 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
609 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
610 * Additions for using the Kitty keyboard protocol. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
611 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
612 static tcap_entry_T builtin_kitty[] = { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
613 // t_TI enables the kitty keyboard protocol. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
614 {(int)KS_CTI, "\033[=1;1u"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
615 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
616 // t_RK requests the kitty keyboard protocol state |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
617 {(int)KS_CRK, "\033[?u"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
618 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
619 // t_TE also disables modifyOtherKeys, because t_TI from xterm may already |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
620 // have been used. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
621 {(int)KS_CTE, "\033[>4;m\033[=0;1u"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
622 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
623 {(int)KS_NAME, NULL} // end marker |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
624 }; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
625 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
626 #ifdef FEAT_TERMGUICOLORS |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
627 /* |
34136
36843e079f64
patch 9.1.0030: Cannot use terminal alternate font
Christian Brabandt <cb@256bit.org>
parents:
34132
diff
changeset
|
628 * Additions for using the RGB colors and terminal font |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
629 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
630 static tcap_entry_T builtin_rgb[] = { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
631 // These are printf strings, not terminal codes. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
632 {(int)KS_8F, "\033[38;2;%lu;%lu;%lum"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
633 {(int)KS_8B, "\033[48;2;%lu;%lu;%lum"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
634 {(int)KS_8U, "\033[58;2;%lu;%lu;%lum"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
635 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
636 {(int)KS_NAME, NULL} // end marker |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
637 }; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
638 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
639 |
34151
e175b87ae80f
patch 9.1.0036: MS-Windows: Warning about unused variable
Christian Brabandt <cb@256bit.org>
parents:
34140
diff
changeset
|
640 #ifdef HAVE_TGETENT |
34136
36843e079f64
patch 9.1.0030: Cannot use terminal alternate font
Christian Brabandt <cb@256bit.org>
parents:
34132
diff
changeset
|
641 static tcap_entry_T special_term[] = { |
36843e079f64
patch 9.1.0030: Cannot use terminal alternate font
Christian Brabandt <cb@256bit.org>
parents:
34132
diff
changeset
|
642 // These are printf strings, not terminal codes. |
36843e079f64
patch 9.1.0030: Cannot use terminal alternate font
Christian Brabandt <cb@256bit.org>
parents:
34132
diff
changeset
|
643 {(int)KS_CF, "\033[%dm"}, |
36843e079f64
patch 9.1.0030: Cannot use terminal alternate font
Christian Brabandt <cb@256bit.org>
parents:
34132
diff
changeset
|
644 {(int)KS_NAME, NULL} // end marker |
36843e079f64
patch 9.1.0030: Cannot use terminal alternate font
Christian Brabandt <cb@256bit.org>
parents:
34132
diff
changeset
|
645 }; |
34151
e175b87ae80f
patch 9.1.0036: MS-Windows: Warning about unused variable
Christian Brabandt <cb@256bit.org>
parents:
34140
diff
changeset
|
646 #endif |
34136
36843e079f64
patch 9.1.0030: Cannot use terminal alternate font
Christian Brabandt <cb@256bit.org>
parents:
34132
diff
changeset
|
647 |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
648 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
649 * iris-ansi for Silicon Graphics machines. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
650 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
651 static tcap_entry_T builtin_iris_ansi[] = { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
652 {(int)KS_CE, "\033[K"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
653 {(int)KS_CD, "\033[J"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
654 {(int)KS_AL, "\033[L"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
655 # ifdef TERMINFO |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
656 {(int)KS_CAL, "\033[%p1%dL"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
657 # else |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
658 {(int)KS_CAL, "\033[%dL"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
659 # endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
660 {(int)KS_DL, "\033[M"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
661 # ifdef TERMINFO |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
662 {(int)KS_CDL, "\033[%p1%dM"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
663 # else |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
664 {(int)KS_CDL, "\033[%dM"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
665 # endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
666 #if 0 // The scroll region is not working as Vim expects. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
667 # ifdef TERMINFO |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
668 {(int)KS_CS, "\033[%i%p1%d;%p2%dr"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
669 # else |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
670 {(int)KS_CS, "\033[%i%d;%dr"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
671 # endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
672 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
673 {(int)KS_CL, "\033[H\033[2J"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
674 {(int)KS_VE, "\033[9/y\033[12/y"}, // These aren't documented |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
675 {(int)KS_VS, "\033[10/y\033[=1h\033[=2l"}, // These aren't documented |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
676 {(int)KS_TI, "\033[=6h"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
677 {(int)KS_TE, "\033[=6l"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
678 {(int)KS_SE, "\033[21;27m"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
679 {(int)KS_SO, "\033[1;7m"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
680 {(int)KS_ME, "\033[m"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
681 {(int)KS_MR, "\033[7m"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
682 {(int)KS_MD, "\033[1m"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
683 {(int)KS_CCO, "8"}, // allow 8 colors |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
684 {(int)KS_CZH, "\033[3m"}, // italic mode on |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
685 {(int)KS_CZR, "\033[23m"}, // italic mode off |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
686 {(int)KS_US, "\033[4m"}, // underline on |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
687 {(int)KS_UE, "\033[24m"}, // underline off |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
688 # ifdef TERMINFO |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
689 {(int)KS_CAB, "\033[4%p1%dm"}, // set background color (ANSI) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
690 {(int)KS_CAF, "\033[3%p1%dm"}, // set foreground color (ANSI) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
691 {(int)KS_CSB, "\033[102;%p1%dm"}, // set screen background color |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
692 {(int)KS_CSF, "\033[101;%p1%dm"}, // set screen foreground color |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
693 # else |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
694 {(int)KS_CAB, "\033[4%dm"}, // set background color (ANSI) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
695 {(int)KS_CAF, "\033[3%dm"}, // set foreground color (ANSI) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
696 {(int)KS_CSB, "\033[102;%dm"}, // set screen background color |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
697 {(int)KS_CSF, "\033[101;%dm"}, // set screen foreground color |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
698 # endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
699 {(int)KS_MS, "y"}, // guessed |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
700 {(int)KS_UT, "y"}, // guessed |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
701 {(int)KS_LE, "\b"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
702 # ifdef TERMINFO |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
703 {(int)KS_CM, "\033[%i%p1%d;%p2%dH"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
704 # else |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
705 {(int)KS_CM, "\033[%i%d;%dH"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
706 # endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
707 {(int)KS_SR, "\033M"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
708 # ifdef TERMINFO |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
709 {(int)KS_CRI, "\033[%p1%dC"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
710 # else |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
711 {(int)KS_CRI, "\033[%dC"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
712 # endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
713 {(int)KS_CIS, "\033P3.y"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
714 {(int)KS_CIE, "\234"}, // ST "String Terminator" |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
715 {(int)KS_TS, "\033P1.y"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
716 {(int)KS_FS, "\234"}, // ST "String Terminator" |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
717 # ifdef TERMINFO |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
718 {(int)KS_CWS, "\033[203;%p1%d;%p2%d/y"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
719 {(int)KS_CWP, "\033[205;%p1%d;%p2%d/y"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
720 # else |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
721 {(int)KS_CWS, "\033[203;%d;%d/y"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
722 {(int)KS_CWP, "\033[205;%d;%d/y"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
723 # endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
724 {K_UP, "\033[A"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
725 {K_DOWN, "\033[B"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
726 {K_LEFT, "\033[D"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
727 {K_RIGHT, "\033[C"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
728 {K_S_UP, "\033[161q"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
729 {K_S_DOWN, "\033[164q"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
730 {K_S_LEFT, "\033[158q"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
731 {K_S_RIGHT, "\033[167q"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
732 {K_F1, "\033[001q"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
733 {K_F2, "\033[002q"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
734 {K_F3, "\033[003q"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
735 {K_F4, "\033[004q"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
736 {K_F5, "\033[005q"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
737 {K_F6, "\033[006q"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
738 {K_F7, "\033[007q"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
739 {K_F8, "\033[008q"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
740 {K_F9, "\033[009q"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
741 {K_F10, "\033[010q"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
742 {K_F11, "\033[011q"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
743 {K_F12, "\033[012q"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
744 {K_S_F1, "\033[013q"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
745 {K_S_F2, "\033[014q"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
746 {K_S_F3, "\033[015q"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
747 {K_S_F4, "\033[016q"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
748 {K_S_F5, "\033[017q"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
749 {K_S_F6, "\033[018q"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
750 {K_S_F7, "\033[019q"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
751 {K_S_F8, "\033[020q"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
752 {K_S_F9, "\033[021q"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
753 {K_S_F10, "\033[022q"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
754 {K_S_F11, "\033[023q"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
755 {K_S_F12, "\033[024q"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
756 {K_INS, "\033[139q"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
757 {K_HOME, "\033[H"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
758 {K_END, "\033[146q"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
759 {K_PAGEUP, "\033[150q"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
760 {K_PAGEDOWN, "\033[154q"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
761 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
762 {(int)KS_NAME, NULL} // end marker |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
763 }; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
764 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
765 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
766 * These codes are valid when nansi.sys or equivalent has been installed. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
767 * Function keys on a PC are preceded with a NUL. These are converted into |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
768 * K_NUL '\316' in mch_inchar(), because we cannot handle NULs in key codes. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
769 * CTRL-arrow is used instead of SHIFT-arrow. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
770 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
771 static tcap_entry_T builtin_pcansi[] = { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
772 {(int)KS_DL, "\033[M"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
773 {(int)KS_AL, "\033[L"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
774 {(int)KS_CE, "\033[K"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
775 {(int)KS_CL, "\033[2J"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
776 {(int)KS_ME, "\033[0m"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
777 {(int)KS_MR, "\033[5m"}, // reverse: black on lightgrey |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
778 {(int)KS_MD, "\033[1m"}, // bold: white text |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
779 {(int)KS_SE, "\033[0m"}, // standout end |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
780 {(int)KS_SO, "\033[31m"}, // standout: white on blue |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
781 {(int)KS_CZH, "\033[34;43m"}, // italic mode: blue text on yellow |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
782 {(int)KS_CZR, "\033[0m"}, // italic mode end |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
783 {(int)KS_US, "\033[36;41m"}, // underscore mode: cyan text on red |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
784 {(int)KS_UE, "\033[0m"}, // underscore mode end |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
785 {(int)KS_CCO, "8"}, // allow 8 colors |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
786 # ifdef TERMINFO |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
787 {(int)KS_CAB, "\033[4%p1%dm"},// set background color |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
788 {(int)KS_CAF, "\033[3%p1%dm"},// set foreground color |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
789 # else |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
790 {(int)KS_CAB, "\033[4%dm"}, // set background color |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
791 {(int)KS_CAF, "\033[3%dm"}, // set foreground color |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
792 # endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
793 {(int)KS_OP, "\033[0m"}, // reset colors |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
794 {(int)KS_MS, "y"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
795 {(int)KS_UT, "y"}, // guessed |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
796 {(int)KS_LE, "\b"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
797 # ifdef TERMINFO |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
798 {(int)KS_CM, "\033[%i%p1%d;%p2%dH"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
799 # else |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
800 {(int)KS_CM, "\033[%i%d;%dH"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
801 # endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
802 # ifdef TERMINFO |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
803 {(int)KS_CRI, "\033[%p1%dC"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
804 # else |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
805 {(int)KS_CRI, "\033[%dC"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
806 # endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
807 {K_UP, "\316H"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
808 {K_DOWN, "\316P"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
809 {K_LEFT, "\316K"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
810 {K_RIGHT, "\316M"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
811 {K_S_LEFT, "\316s"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
812 {K_S_RIGHT, "\316t"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
813 {K_F1, "\316;"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
814 {K_F2, "\316<"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
815 {K_F3, "\316="}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
816 {K_F4, "\316>"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
817 {K_F5, "\316?"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
818 {K_F6, "\316@"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
819 {K_F7, "\316A"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
820 {K_F8, "\316B"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
821 {K_F9, "\316C"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
822 {K_F10, "\316D"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
823 {K_F11, "\316\205"}, // guessed |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
824 {K_F12, "\316\206"}, // guessed |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
825 {K_S_F1, "\316T"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
826 {K_S_F2, "\316U"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
827 {K_S_F3, "\316V"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
828 {K_S_F4, "\316W"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
829 {K_S_F5, "\316X"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
830 {K_S_F6, "\316Y"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
831 {K_S_F7, "\316Z"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
832 {K_S_F8, "\316["}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
833 {K_S_F9, "\316\\"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
834 {K_S_F10, "\316]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
835 {K_S_F11, "\316\207"}, // guessed |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
836 {K_S_F12, "\316\210"}, // guessed |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
837 {K_INS, "\316R"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
838 {K_DEL, "\316S"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
839 {K_HOME, "\316G"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
840 {K_END, "\316O"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
841 {K_PAGEDOWN, "\316Q"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
842 {K_PAGEUP, "\316I"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
843 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
844 {(int)KS_NAME, NULL} // end marker |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
845 }; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
846 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
847 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
848 * These codes are valid for the Win32 Console. The entries that start with |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
849 * ESC | are translated into console calls in os_win32.c. The function keys |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
850 * are also translated in os_win32.c. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
851 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
852 static tcap_entry_T builtin_win32[] = { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
853 {(int)KS_CE, "\033|K"}, // clear to end of line |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
854 {(int)KS_AL, "\033|L"}, // add new blank line |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
855 # ifdef TERMINFO |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
856 {(int)KS_CAL, "\033|%p1%dL"}, // add number of new blank lines |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
857 # else |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
858 {(int)KS_CAL, "\033|%dL"}, // add number of new blank lines |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
859 # endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
860 {(int)KS_DL, "\033|M"}, // delete line |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
861 # ifdef TERMINFO |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
862 {(int)KS_CDL, "\033|%p1%dM"}, // delete number of lines |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
863 {(int)KS_CSV, "\033|%p1%d;%p2%dV"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
864 # else |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
865 {(int)KS_CDL, "\033|%dM"}, // delete number of lines |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
866 {(int)KS_CSV, "\033|%d;%dV"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
867 # endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
868 {(int)KS_CL, "\033|J"}, // clear screen |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
869 {(int)KS_CD, "\033|j"}, // clear to end of display |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
870 {(int)KS_VI, "\033|v"}, // cursor invisible |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
871 {(int)KS_VE, "\033|V"}, // cursor visible |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
872 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
873 {(int)KS_ME, "\033|0m"}, // normal |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
874 {(int)KS_MR, "\033|112m"}, // reverse: black on lightgray |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
875 {(int)KS_MD, "\033|15m"}, // bold: white on black |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
876 #if 1 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
877 {(int)KS_SO, "\033|31m"}, // standout: white on blue |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
878 {(int)KS_SE, "\033|0m"}, // standout end |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
879 #else |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
880 {(int)KS_SO, "\033|F"}, // standout: high intensity |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
881 {(int)KS_SE, "\033|f"}, // standout end |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
882 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
883 {(int)KS_CZH, "\033|225m"}, // italic: blue text on yellow |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
884 {(int)KS_CZR, "\033|0m"}, // italic end |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
885 {(int)KS_US, "\033|67m"}, // underscore: cyan text on red |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
886 {(int)KS_UE, "\033|0m"}, // underscore end |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
887 {(int)KS_CCO, "16"}, // allow 16 colors |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
888 # ifdef TERMINFO |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
889 {(int)KS_CAB, "\033|%p1%db"}, // set background color |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
890 {(int)KS_CAF, "\033|%p1%df"}, // set foreground color |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
891 # else |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
892 {(int)KS_CAB, "\033|%db"}, // set background color |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
893 {(int)KS_CAF, "\033|%df"}, // set foreground color |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
894 # endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
895 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
896 {(int)KS_MS, "y"}, // save to move cur in reverse mode |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
897 {(int)KS_UT, "y"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
898 {(int)KS_XN, "y"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
899 {(int)KS_LE, "\b"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
900 # ifdef TERMINFO |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
901 {(int)KS_CM, "\033|%i%p1%d;%p2%dH"}, // cursor motion |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
902 # else |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
903 {(int)KS_CM, "\033|%i%d;%dH"}, // cursor motion |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
904 # endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
905 {(int)KS_VB, "\033|B"}, // visual bell |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
906 {(int)KS_TI, "\033|S"}, // put terminal in termcap mode |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
907 {(int)KS_TE, "\033|E"}, // out of termcap mode |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
908 # ifdef TERMINFO |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
909 {(int)KS_CS, "\033|%i%p1%d;%p2%dr"}, // scroll region |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
910 # else |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
911 {(int)KS_CS, "\033|%i%d;%dr"}, // scroll region |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
912 # endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
913 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
914 {K_UP, "\316H"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
915 {K_DOWN, "\316P"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
916 {K_LEFT, "\316K"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
917 {K_RIGHT, "\316M"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
918 {K_S_UP, "\316\304"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
919 {K_S_DOWN, "\316\317"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
920 {K_S_LEFT, "\316\311"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
921 {K_C_LEFT, "\316s"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
922 {K_S_RIGHT, "\316\313"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
923 {K_C_RIGHT, "\316t"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
924 {K_S_TAB, "\316\017"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
925 {K_F1, "\316;"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
926 {K_F2, "\316<"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
927 {K_F3, "\316="}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
928 {K_F4, "\316>"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
929 {K_F5, "\316?"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
930 {K_F6, "\316@"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
931 {K_F7, "\316A"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
932 {K_F8, "\316B"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
933 {K_F9, "\316C"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
934 {K_F10, "\316D"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
935 {K_F11, "\316\205"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
936 {K_F12, "\316\206"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
937 {K_S_F1, "\316T"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
938 {K_S_F2, "\316U"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
939 {K_S_F3, "\316V"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
940 {K_S_F4, "\316W"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
941 {K_S_F5, "\316X"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
942 {K_S_F6, "\316Y"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
943 {K_S_F7, "\316Z"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
944 {K_S_F8, "\316["}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
945 {K_S_F9, "\316\\"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
946 {K_S_F10, "\316]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
947 {K_S_F11, "\316\207"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
948 {K_S_F12, "\316\210"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
949 {K_INS, "\316R"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
950 {K_DEL, "\316S"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
951 {K_HOME, "\316G"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
952 {K_S_HOME, "\316\302"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
953 {K_C_HOME, "\316w"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
954 {K_END, "\316O"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
955 {K_S_END, "\316\315"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
956 {K_C_END, "\316u"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
957 {K_PAGEDOWN, "\316Q"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
958 {K_PAGEUP, "\316I"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
959 {K_KPLUS, "\316N"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
960 {K_KMINUS, "\316J"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
961 {K_KMULTIPLY, "\316\067"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
962 {K_K0, "\316\332"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
963 {K_K1, "\316\336"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
964 {K_K2, "\316\342"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
965 {K_K3, "\316\346"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
966 {K_K4, "\316\352"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
967 {K_K5, "\316\356"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
968 {K_K6, "\316\362"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
969 {K_K7, "\316\366"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
970 {K_K8, "\316\372"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
971 {K_K9, "\316\376"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
972 {K_BS, "\316x"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
973 {K_S_BS, "\316y"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
974 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
975 {(int)KS_NAME, NULL} // end marker |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
976 }; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
977 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
978 #if defined(FEAT_GUI) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
979 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
980 * GUI uses made-up codes, only used inside Vim. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
981 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
982 static tcap_entry_T builtin_gui[] = { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
983 {(int)KS_CE, "\033|$"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
984 {(int)KS_AL, "\033|i"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
985 # ifdef TERMINFO |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
986 {(int)KS_CAL, "\033|%p1%dI"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
987 # else |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
988 {(int)KS_CAL, "\033|%dI"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
989 # endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
990 {(int)KS_DL, "\033|d"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
991 # ifdef TERMINFO |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
992 {(int)KS_CDL, "\033|%p1%dD"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
993 {(int)KS_CS, "\033|%p1%d;%p2%dR"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
994 {(int)KS_CSV, "\033|%p1%d;%p2%dV"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
995 # else |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
996 {(int)KS_CDL, "\033|%dD"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
997 {(int)KS_CS, "\033|%d;%dR"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
998 {(int)KS_CSV, "\033|%d;%dV"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
999 # endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1000 {(int)KS_CL, "\033|C"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1001 // attributes switched on with 'h', off with * 'H' |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1002 {(int)KS_ME, "\033|31H"}, // HL_ALL |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1003 {(int)KS_MR, "\033|1h"}, // HL_INVERSE |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1004 {(int)KS_MD, "\033|2h"}, // HL_BOLD |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1005 {(int)KS_SE, "\033|16H"}, // HL_STANDOUT |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1006 {(int)KS_SO, "\033|16h"}, // HL_STANDOUT |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1007 {(int)KS_UE, "\033|8H"}, // HL_UNDERLINE |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1008 {(int)KS_US, "\033|8h"}, // HL_UNDERLINE |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1009 {(int)KS_UCE, "\033|8C"}, // HL_UNDERCURL |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1010 {(int)KS_UCS, "\033|8c"}, // HL_UNDERCURL |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1011 {(int)KS_STE, "\033|4C"}, // HL_STRIKETHROUGH |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1012 {(int)KS_STS, "\033|4c"}, // HL_STRIKETHROUGH |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1013 {(int)KS_CZR, "\033|4H"}, // HL_ITALIC |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1014 {(int)KS_CZH, "\033|4h"}, // HL_ITALIC |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1015 {(int)KS_VB, "\033|f"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1016 {(int)KS_MS, "y"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1017 {(int)KS_UT, "y"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1018 {(int)KS_XN, "y"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1019 {(int)KS_LE, "\b"}, // cursor-left = BS |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1020 {(int)KS_ND, "\014"}, // cursor-right = CTRL-L |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1021 # ifdef TERMINFO |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1022 {(int)KS_CM, "\033|%p1%d;%p2%dM"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1023 # else |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1024 {(int)KS_CM, "\033|%d;%dM"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1025 # endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1026 // there are no key sequences here, the GUI sequences are recognized |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1027 // in check_termcode() |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1028 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1029 {(int)KS_NAME, NULL} // end marker |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1030 }; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1031 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1032 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1033 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1034 * Amiga console window, default for Amiga. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1035 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1036 static tcap_entry_T builtin_amiga[] = { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1037 {(int)KS_CE, "\033[K"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1038 {(int)KS_CD, "\033[J"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1039 {(int)KS_AL, "\033[L"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1040 # ifdef TERMINFO |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1041 {(int)KS_CAL, "\033[%p1%dL"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1042 # else |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1043 {(int)KS_CAL, "\033[%dL"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1044 # endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1045 {(int)KS_DL, "\033[M"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1046 # ifdef TERMINFO |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1047 {(int)KS_CDL, "\033[%p1%dM"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1048 # else |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1049 {(int)KS_CDL, "\033[%dM"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1050 # endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1051 {(int)KS_CL, "\014"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1052 {(int)KS_VI, "\033[0 p"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1053 {(int)KS_VE, "\033[1 p"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1054 {(int)KS_ME, "\033[0m"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1055 {(int)KS_MR, "\033[7m"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1056 {(int)KS_MD, "\033[1m"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1057 {(int)KS_SE, "\033[0m"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1058 {(int)KS_SO, "\033[33m"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1059 {(int)KS_US, "\033[4m"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1060 {(int)KS_UE, "\033[0m"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1061 {(int)KS_CZH, "\033[3m"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1062 {(int)KS_CZR, "\033[0m"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1063 #if defined(__amigaos4__) || defined(__MORPHOS__) || defined(__AROS__) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1064 {(int)KS_CCO, "8"}, // allow 8 colors |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1065 # ifdef TERMINFO |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1066 {(int)KS_CAB, "\033[4%p1%dm"},// set background color |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1067 {(int)KS_CAF, "\033[3%p1%dm"},// set foreground color |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1068 # else |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1069 {(int)KS_CAB, "\033[4%dm"}, // set background color |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1070 {(int)KS_CAF, "\033[3%dm"}, // set foreground color |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1071 # endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1072 {(int)KS_OP, "\033[m"}, // reset colors |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1073 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1074 {(int)KS_MS, "y"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1075 {(int)KS_UT, "y"}, // guessed |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1076 {(int)KS_LE, "\b"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1077 # ifdef TERMINFO |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1078 {(int)KS_CM, "\033[%i%p1%d;%p2%dH"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1079 # else |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1080 {(int)KS_CM, "\033[%i%d;%dH"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1081 # endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1082 #if defined(__MORPHOS__) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1083 {(int)KS_SR, "\033M"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1084 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1085 # ifdef TERMINFO |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1086 {(int)KS_CRI, "\033[%p1%dC"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1087 # else |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1088 {(int)KS_CRI, "\033[%dC"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1089 # endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1090 {K_UP, "\233A"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1091 {K_DOWN, "\233B"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1092 {K_LEFT, "\233D"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1093 {K_RIGHT, "\233C"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1094 {K_S_UP, "\233T"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1095 {K_S_DOWN, "\233S"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1096 {K_S_LEFT, "\233 A"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1097 {K_S_RIGHT, "\233 @"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1098 {K_S_TAB, "\233Z"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1099 {K_F1, "\233\060~"},// some compilers don't dig "\2330" |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1100 {K_F2, "\233\061~"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1101 {K_F3, "\233\062~"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1102 {K_F4, "\233\063~"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1103 {K_F5, "\233\064~"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1104 {K_F6, "\233\065~"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1105 {K_F7, "\233\066~"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1106 {K_F8, "\233\067~"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1107 {K_F9, "\233\070~"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1108 {K_F10, "\233\071~"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1109 {K_S_F1, "\233\061\060~"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1110 {K_S_F2, "\233\061\061~"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1111 {K_S_F3, "\233\061\062~"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1112 {K_S_F4, "\233\061\063~"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1113 {K_S_F5, "\233\061\064~"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1114 {K_S_F6, "\233\061\065~"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1115 {K_S_F7, "\233\061\066~"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1116 {K_S_F8, "\233\061\067~"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1117 {K_S_F9, "\233\061\070~"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1118 {K_S_F10, "\233\061\071~"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1119 {K_HELP, "\233?~"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1120 {K_INS, "\233\064\060~"}, // 101 key keyboard |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1121 {K_PAGEUP, "\233\064\061~"}, // 101 key keyboard |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1122 {K_PAGEDOWN, "\233\064\062~"}, // 101 key keyboard |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1123 {K_HOME, "\233\064\064~"}, // 101 key keyboard |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1124 {K_END, "\233\064\065~"}, // 101 key keyboard |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1125 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1126 {BT_EXTRA_KEYS, ""}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1127 {TERMCAP2KEY('#', '2'), "\233\065\064~"}, // shifted home key |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1128 {TERMCAP2KEY('#', '3'), "\233\065\060~"}, // shifted insert key |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1129 {TERMCAP2KEY('*', '7'), "\233\065\065~"}, // shifted end key |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1130 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1131 {(int)KS_NAME, NULL} // end marker |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1132 }; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1133 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1134 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1135 * The most minimal terminal: only clear screen and cursor positioning. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1136 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1137 static tcap_entry_T builtin_dumb[] = { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1138 {(int)KS_CL, "\014"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1139 #ifdef TERMINFO |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1140 {(int)KS_CM, "\033[%i%p1%d;%p2%dH"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1141 #else |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1142 {(int)KS_CM, "\033[%i%d;%dH"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1143 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1144 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1145 {(int)KS_NAME, NULL} // end marker |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1146 }; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1147 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1148 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1149 * Terminal used for debugging. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1150 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1151 static tcap_entry_T builtin_debug[] = { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1152 {(int)KS_CE, "[CE]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1153 {(int)KS_CD, "[CD]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1154 {(int)KS_AL, "[AL]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1155 # ifdef TERMINFO |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1156 {(int)KS_CAL, "[CAL%p1%d]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1157 # else |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1158 {(int)KS_CAL, "[CAL%d]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1159 # endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1160 {(int)KS_DL, "[DL]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1161 # ifdef TERMINFO |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1162 {(int)KS_CDL, "[CDL%p1%d]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1163 # else |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1164 {(int)KS_CDL, "[CDL%d]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1165 # endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1166 # ifdef TERMINFO |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1167 {(int)KS_CS, "[%p1%dCS%p2%d]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1168 # else |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1169 {(int)KS_CS, "[%dCS%d]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1170 # endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1171 # ifdef TERMINFO |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1172 {(int)KS_CSV, "[%p1%dCSV%p2%d]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1173 # else |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1174 {(int)KS_CSV, "[%dCSV%d]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1175 # endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1176 # ifdef TERMINFO |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1177 {(int)KS_CAB, "[CAB%p1%d]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1178 {(int)KS_CAF, "[CAF%p1%d]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1179 {(int)KS_CSB, "[CSB%p1%d]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1180 {(int)KS_CSF, "[CSF%p1%d]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1181 # else |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1182 {(int)KS_CAB, "[CAB%d]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1183 {(int)KS_CAF, "[CAF%d]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1184 {(int)KS_CSB, "[CSB%d]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1185 {(int)KS_CSF, "[CSF%d]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1186 # endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1187 {(int)KS_CAU, "[CAU%d]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1188 {(int)KS_OP, "[OP]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1189 {(int)KS_LE, "[LE]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1190 {(int)KS_CL, "[CL]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1191 {(int)KS_VI, "[VI]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1192 {(int)KS_VE, "[VE]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1193 {(int)KS_VS, "[VS]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1194 {(int)KS_ME, "[ME]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1195 {(int)KS_MR, "[MR]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1196 {(int)KS_MB, "[MB]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1197 {(int)KS_MD, "[MD]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1198 {(int)KS_SE, "[SE]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1199 {(int)KS_SO, "[SO]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1200 {(int)KS_UE, "[UE]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1201 {(int)KS_US, "[US]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1202 {(int)KS_UCE, "[UCE]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1203 {(int)KS_UCS, "[UCS]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1204 {(int)KS_USS, "[USS]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1205 {(int)KS_DS, "[DS]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1206 {(int)KS_CDS, "[CDS]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1207 {(int)KS_STE, "[STE]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1208 {(int)KS_STS, "[STS]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1209 {(int)KS_MS, "[MS]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1210 {(int)KS_UT, "[UT]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1211 {(int)KS_XN, "[XN]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1212 # ifdef TERMINFO |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1213 {(int)KS_CM, "[%p1%dCM%p2%d]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1214 # else |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1215 {(int)KS_CM, "[%dCM%d]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1216 # endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1217 {(int)KS_SR, "[SR]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1218 # ifdef TERMINFO |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1219 {(int)KS_CRI, "[CRI%p1%d]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1220 # else |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1221 {(int)KS_CRI, "[CRI%d]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1222 # endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1223 {(int)KS_VB, "[VB]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1224 {(int)KS_KS, "[KS]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1225 {(int)KS_KE, "[KE]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1226 {(int)KS_TI, "[TI]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1227 {(int)KS_TE, "[TE]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1228 {(int)KS_CIS, "[CIS]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1229 {(int)KS_CIE, "[CIE]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1230 {(int)KS_CSC, "[CSC]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1231 {(int)KS_CEC, "[CEC]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1232 {(int)KS_TS, "[TS]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1233 {(int)KS_FS, "[FS]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1234 # ifdef TERMINFO |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1235 {(int)KS_CWS, "[%p1%dCWS%p2%d]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1236 {(int)KS_CWP, "[%p1%dCWP%p2%d]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1237 # else |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1238 {(int)KS_CWS, "[%dCWS%d]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1239 {(int)KS_CWP, "[%dCWP%d]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1240 # endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1241 {(int)KS_CRV, "[CRV]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1242 {(int)KS_CXM, "[CXM]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1243 {(int)KS_U7, "[U7]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1244 {(int)KS_RFG, "[RFG]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1245 {(int)KS_RBG, "[RBG]"}, |
34136
36843e079f64
patch 9.1.0030: Cannot use terminal alternate font
Christian Brabandt <cb@256bit.org>
parents:
34132
diff
changeset
|
1246 {(int)KS_CF, "[CF%d]"}, |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1247 {K_UP, "[KU]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1248 {K_DOWN, "[KD]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1249 {K_LEFT, "[KL]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1250 {K_RIGHT, "[KR]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1251 {K_XUP, "[xKU]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1252 {K_XDOWN, "[xKD]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1253 {K_XLEFT, "[xKL]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1254 {K_XRIGHT, "[xKR]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1255 {K_S_UP, "[S-KU]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1256 {K_S_DOWN, "[S-KD]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1257 {K_S_LEFT, "[S-KL]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1258 {K_C_LEFT, "[C-KL]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1259 {K_S_RIGHT, "[S-KR]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1260 {K_C_RIGHT, "[C-KR]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1261 {K_F1, "[F1]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1262 {K_XF1, "[xF1]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1263 {K_F2, "[F2]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1264 {K_XF2, "[xF2]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1265 {K_F3, "[F3]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1266 {K_XF3, "[xF3]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1267 {K_F4, "[F4]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1268 {K_XF4, "[xF4]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1269 {K_F5, "[F5]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1270 {K_F6, "[F6]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1271 {K_F7, "[F7]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1272 {K_F8, "[F8]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1273 {K_F9, "[F9]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1274 {K_F10, "[F10]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1275 {K_F11, "[F11]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1276 {K_F12, "[F12]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1277 {K_S_F1, "[S-F1]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1278 {K_S_XF1, "[S-xF1]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1279 {K_S_F2, "[S-F2]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1280 {K_S_XF2, "[S-xF2]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1281 {K_S_F3, "[S-F3]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1282 {K_S_XF3, "[S-xF3]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1283 {K_S_F4, "[S-F4]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1284 {K_S_XF4, "[S-xF4]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1285 {K_S_F5, "[S-F5]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1286 {K_S_F6, "[S-F6]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1287 {K_S_F7, "[S-F7]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1288 {K_S_F8, "[S-F8]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1289 {K_S_F9, "[S-F9]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1290 {K_S_F10, "[S-F10]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1291 {K_S_F11, "[S-F11]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1292 {K_S_F12, "[S-F12]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1293 {K_HELP, "[HELP]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1294 {K_UNDO, "[UNDO]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1295 {K_BS, "[BS]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1296 {K_INS, "[INS]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1297 {K_KINS, "[KINS]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1298 {K_DEL, "[DEL]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1299 {K_KDEL, "[KDEL]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1300 {K_HOME, "[HOME]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1301 {K_S_HOME, "[C-HOME]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1302 {K_C_HOME, "[C-HOME]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1303 {K_KHOME, "[KHOME]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1304 {K_XHOME, "[XHOME]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1305 {K_ZHOME, "[ZHOME]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1306 {K_END, "[END]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1307 {K_S_END, "[C-END]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1308 {K_C_END, "[C-END]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1309 {K_KEND, "[KEND]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1310 {K_XEND, "[XEND]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1311 {K_ZEND, "[ZEND]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1312 {K_PAGEUP, "[PAGEUP]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1313 {K_PAGEDOWN, "[PAGEDOWN]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1314 {K_KPAGEUP, "[KPAGEUP]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1315 {K_KPAGEDOWN, "[KPAGEDOWN]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1316 {K_MOUSE, "[MOUSE]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1317 {K_KPLUS, "[KPLUS]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1318 {K_KMINUS, "[KMINUS]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1319 {K_KDIVIDE, "[KDIVIDE]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1320 {K_KMULTIPLY, "[KMULTIPLY]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1321 {K_KENTER, "[KENTER]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1322 {K_KPOINT, "[KPOINT]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1323 {K_PS, "[PASTE-START]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1324 {K_PE, "[PASTE-END]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1325 {K_K0, "[K0]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1326 {K_K1, "[K1]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1327 {K_K2, "[K2]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1328 {K_K3, "[K3]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1329 {K_K4, "[K4]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1330 {K_K5, "[K5]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1331 {K_K6, "[K6]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1332 {K_K7, "[K7]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1333 {K_K8, "[K8]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1334 {K_K9, "[K9]"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1335 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1336 {(int)KS_NAME, NULL} // end marker |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1337 }; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1338 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1339 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1340 * List of builtin terminals. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1341 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1342 typedef struct { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1343 char *bitc_name; // name, such as "xterm" |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1344 tcap_entry_T *bitc_table; // table with entries for bitc_name |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1345 } builtin_tcap_T; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1346 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1347 builtin_tcap_T builtin_terminals[] = { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1348 // Unix and Generic |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1349 {"ansi", builtin_ansi}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1350 {"vt320", builtin_vt320}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1351 {"vt52", builtin_vt52}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1352 {"xterm", builtin_xterm}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1353 {"iris-ansi", builtin_iris_ansi}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1354 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1355 // MS-Windows |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1356 {"pcansi", builtin_pcansi}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1357 {"win32", builtin_win32}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1358 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1359 // Other systems |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1360 #if defined(FEAT_GUI) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1361 {"gui", builtin_gui}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1362 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1363 {"amiga", builtin_amiga}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1364 {"dumb", builtin_dumb}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1365 {"debug", builtin_debug}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1366 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1367 {NULL, NULL}, // end marker |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1368 }; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1369 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1370 #if defined(FEAT_TERMGUICOLORS) || defined(PROTO) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1371 static guicolor_T |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1372 termgui_mch_get_color(char_u *name) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1373 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1374 return gui_get_color_cmn(name); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1375 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1376 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1377 guicolor_T |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1378 termgui_get_color(char_u *name) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1379 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1380 guicolor_T t; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1381 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1382 if (*name == NUL) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1383 return INVALCOLOR; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1384 t = termgui_mch_get_color(name); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1385 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1386 if (t == INVALCOLOR) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1387 semsg(_(e_cannot_allocate_color_str), name); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1388 return t; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1389 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1390 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1391 guicolor_T |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1392 termgui_mch_get_rgb(guicolor_T color) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1393 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1394 return color; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1395 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1396 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1397 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1398 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1399 * DEFAULT_TERM is used, when no terminal is specified with -T option or $TERM. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1400 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1401 #ifdef AMIGA |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1402 # define DEFAULT_TERM (char_u *)"amiga" |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1403 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1404 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1405 #ifdef MSWIN |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1406 # define DEFAULT_TERM (char_u *)"win32" |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1407 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1408 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1409 #if defined(UNIX) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1410 # define DEFAULT_TERM (char_u *)"ansi" |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1411 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1412 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1413 #ifdef VMS |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1414 # define DEFAULT_TERM (char_u *)"vt320" |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1415 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1416 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1417 #ifdef __HAIKU__ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1418 # undef DEFAULT_TERM |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1419 # define DEFAULT_TERM (char_u *)"xterm" |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1420 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1421 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1422 #ifndef DEFAULT_TERM |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1423 # define DEFAULT_TERM (char_u *)"dumb" |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1424 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1425 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1426 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1427 * Term_strings contains currently used terminal output strings. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1428 * It is initialized with the default values by parse_builtin_tcap(). |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1429 * The values can be changed by setting the option with the same name. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1430 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1431 char_u *(term_strings[(int)KS_LAST + 1]); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1432 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1433 static int need_gather = FALSE; // need to fill termleader[] |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1434 static char_u termleader[256 + 1]; // for check_termcode() |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1435 #ifdef FEAT_TERMRESPONSE |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1436 static int check_for_codes = FALSE; // check for key code response |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1437 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1438 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1439 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1440 * Structure and table to store terminal features that can be detected by |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1441 * querying the terminal. Either by inspecting the termresponse or a more |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1442 * specific request. Besides this there are: |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1443 * t_colors - number of colors supported |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1444 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1445 typedef struct { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1446 char *tpr_name; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1447 int tpr_set_by_termresponse; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1448 int tpr_status; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1449 } termprop_T; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1450 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1451 // Values for tpr_status. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1452 #define TPR_UNKNOWN 'u' |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1453 #define TPR_YES 'y' |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1454 #define TPR_NO 'n' |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1455 #define TPR_MOUSE_XTERM 'x' // use "xterm" for 'ttymouse' |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1456 #define TPR_MOUSE_XTERM2 '2' // use "xterm2" for 'ttymouse' |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1457 #define TPR_MOUSE_SGR 's' // use "sgr" for 'ttymouse' |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1458 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1459 // can request the cursor style without messing up the display |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1460 #define TPR_CURSOR_STYLE 0 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1461 // can request the cursor blink mode without messing up the display |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1462 #define TPR_CURSOR_BLINK 1 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1463 // can set the underline color with t_8u without resetting other colors |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1464 #define TPR_UNDERLINE_RGB 2 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1465 // mouse support - TPR_MOUSE_XTERM, TPR_MOUSE_XTERM2 or TPR_MOUSE_SGR |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1466 #define TPR_MOUSE 3 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1467 // term response indicates kitty |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1468 #define TPR_KITTY 4 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1469 // table size |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1470 #define TPR_COUNT 5 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1471 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1472 static termprop_T term_props[TPR_COUNT]; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1473 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1474 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1475 * Initialize the term_props table. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1476 * When "all" is FALSE only set those that are detected from the version |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1477 * response. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1478 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1479 void |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1480 init_term_props(int all) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1481 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1482 int i; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1483 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1484 term_props[TPR_CURSOR_STYLE].tpr_name = "cursor_style"; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1485 term_props[TPR_CURSOR_STYLE].tpr_set_by_termresponse = FALSE; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1486 term_props[TPR_CURSOR_BLINK].tpr_name = "cursor_blink_mode"; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1487 term_props[TPR_CURSOR_BLINK].tpr_set_by_termresponse = FALSE; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1488 term_props[TPR_UNDERLINE_RGB].tpr_name = "underline_rgb"; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1489 term_props[TPR_UNDERLINE_RGB].tpr_set_by_termresponse = TRUE; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1490 term_props[TPR_MOUSE].tpr_name = "mouse"; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1491 term_props[TPR_MOUSE].tpr_set_by_termresponse = TRUE; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1492 term_props[TPR_KITTY].tpr_name = "kitty"; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1493 term_props[TPR_KITTY].tpr_set_by_termresponse = FALSE; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1494 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1495 for (i = 0; i < TPR_COUNT; ++i) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1496 if (all || term_props[i].tpr_set_by_termresponse) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1497 term_props[i].tpr_status = TPR_UNKNOWN; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1498 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1499 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1500 #if defined(FEAT_EVAL) || defined(PROTO) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1501 void |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1502 f_terminalprops(typval_T *argvars UNUSED, typval_T *rettv) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1503 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1504 # ifdef FEAT_TERMRESPONSE |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1505 int i; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1506 # endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1507 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1508 if (rettv_dict_alloc(rettv) == FAIL) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1509 return; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1510 # ifdef FEAT_TERMRESPONSE |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1511 for (i = 0; i < TPR_COUNT; ++i) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1512 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1513 char_u value[2]; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1514 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1515 value[0] = term_props[i].tpr_status; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1516 value[1] = NUL; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1517 dict_add_string(rettv->vval.v_dict, term_props[i].tpr_name, value); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1518 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1519 # endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1520 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1521 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1522 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1523 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1524 * Find the builtin termcap entries for "term". |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1525 * This also recognizes similar names. E.g. "xterm-256color" finds the "xterm" |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1526 * entry. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1527 * Returns NULL when "term" is not found. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1528 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1529 static tcap_entry_T * |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1530 find_builtin_term(char_u *term) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1531 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1532 for (int i = 0; ; ++i) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1533 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1534 char_u *name = (char_u *)builtin_terminals[i].bitc_name; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1535 if (name == NULL) // end marker |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1536 break; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1537 #ifdef UNIX |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1538 if (STRCMP(name, "iris-ansi") == 0 && vim_is_iris(term)) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1539 return builtin_terminals[i].bitc_table; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1540 if (STRCMP(name, "xterm") == 0 && vim_is_xterm(term)) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1541 return builtin_terminals[i].bitc_table; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1542 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1543 #ifdef VMS |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1544 if (STRCMP(name, "vt320") == 0 && vim_is_vt300(term)) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1545 return builtin_terminals[i].bitc_table; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1546 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1547 if (STRCMP(term, name) == 0) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1548 return builtin_terminals[i].bitc_table; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1549 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1550 return NULL; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1551 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1552 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1553 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1554 * Apply entries from a builtin termcap. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1555 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1556 static void |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1557 apply_builtin_tcap(char_u *term, tcap_entry_T *entries, int overwrite) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1558 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1559 int term_8bit = term_is_8bit(term); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1560 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1561 for (tcap_entry_T *p = entries; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1562 p->bt_entry != (int)KS_NAME && p->bt_entry != BT_EXTRA_KEYS; ++p) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1563 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1564 if ((int)p->bt_entry >= 0) // KS_xx entry |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1565 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1566 // Only set the value if it wasn't set yet or "overwrite" is TRUE. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1567 if (term_strings[p->bt_entry] == NULL |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1568 || term_strings[p->bt_entry] == empty_option |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1569 || overwrite) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1570 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1571 #ifdef FEAT_EVAL |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1572 int opt_idx = -1; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1573 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1574 // 8bit terminal: use CSI instead of <Esc>[ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1575 if (term_8bit && term_7to8bit((char_u *)p->bt_string) != 0) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1576 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1577 char_u *s, *t; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1578 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1579 s = vim_strsave((char_u *)p->bt_string); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1580 if (s != NULL) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1581 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1582 for (t = s; *t; ++t) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1583 if (term_7to8bit(t)) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1584 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1585 *t = term_7to8bit(t); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1586 STRMOVE(t + 1, t + 2); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1587 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1588 term_strings[p->bt_entry] = s; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1589 #ifdef FEAT_EVAL |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1590 opt_idx = |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1591 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1592 set_term_option_alloced( |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1593 &term_strings[p->bt_entry]); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1594 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1595 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1596 else |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1597 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1598 term_strings[p->bt_entry] = (char_u *)p->bt_string; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1599 #ifdef FEAT_EVAL |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1600 opt_idx = get_term_opt_idx(&term_strings[p->bt_entry]); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1601 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1602 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1603 #ifdef FEAT_EVAL |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1604 set_term_option_sctx_idx(NULL, opt_idx); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1605 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1606 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1607 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1608 else |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1609 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1610 char_u name[2]; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1611 name[0] = KEY2TERMCAP0((int)p->bt_entry); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1612 name[1] = KEY2TERMCAP1((int)p->bt_entry); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1613 if (find_termcode(name) == NULL || overwrite) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1614 add_termcode(name, (char_u *)p->bt_string, term_8bit); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1615 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1616 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1617 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1618 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1619 /* |
33397
23a824d80de3
patch 9.0.1957: termcap options should change when setting keyprotocol
Christian Brabandt <cb@256bit.org>
parents:
33223
diff
changeset
|
1620 * Apply builtin termcap entries for a given keyprotocol. |
23a824d80de3
patch 9.0.1957: termcap options should change when setting keyprotocol
Christian Brabandt <cb@256bit.org>
parents:
33223
diff
changeset
|
1621 */ |
23a824d80de3
patch 9.0.1957: termcap options should change when setting keyprotocol
Christian Brabandt <cb@256bit.org>
parents:
33223
diff
changeset
|
1622 void |
23a824d80de3
patch 9.0.1957: termcap options should change when setting keyprotocol
Christian Brabandt <cb@256bit.org>
parents:
33223
diff
changeset
|
1623 apply_keyprotocol(char_u *term, keyprot_T prot) |
23a824d80de3
patch 9.0.1957: termcap options should change when setting keyprotocol
Christian Brabandt <cb@256bit.org>
parents:
33223
diff
changeset
|
1624 { |
23a824d80de3
patch 9.0.1957: termcap options should change when setting keyprotocol
Christian Brabandt <cb@256bit.org>
parents:
33223
diff
changeset
|
1625 if (prot == KEYPROTOCOL_KITTY) |
23a824d80de3
patch 9.0.1957: termcap options should change when setting keyprotocol
Christian Brabandt <cb@256bit.org>
parents:
33223
diff
changeset
|
1626 apply_builtin_tcap(term, builtin_kitty, TRUE); |
23a824d80de3
patch 9.0.1957: termcap options should change when setting keyprotocol
Christian Brabandt <cb@256bit.org>
parents:
33223
diff
changeset
|
1627 if (prot == KEYPROTOCOL_MOK2) |
23a824d80de3
patch 9.0.1957: termcap options should change when setting keyprotocol
Christian Brabandt <cb@256bit.org>
parents:
33223
diff
changeset
|
1628 apply_builtin_tcap(term, builtin_mok2, TRUE); |
23a824d80de3
patch 9.0.1957: termcap options should change when setting keyprotocol
Christian Brabandt <cb@256bit.org>
parents:
33223
diff
changeset
|
1629 |
23a824d80de3
patch 9.0.1957: termcap options should change when setting keyprotocol
Christian Brabandt <cb@256bit.org>
parents:
33223
diff
changeset
|
1630 if (prot != KEYPROTOCOL_NONE) |
23a824d80de3
patch 9.0.1957: termcap options should change when setting keyprotocol
Christian Brabandt <cb@256bit.org>
parents:
33223
diff
changeset
|
1631 // Some function keys may accept modifiers even though the |
23a824d80de3
patch 9.0.1957: termcap options should change when setting keyprotocol
Christian Brabandt <cb@256bit.org>
parents:
33223
diff
changeset
|
1632 // terminfo/termcap entry does not indicate this. |
23a824d80de3
patch 9.0.1957: termcap options should change when setting keyprotocol
Christian Brabandt <cb@256bit.org>
parents:
33223
diff
changeset
|
1633 accept_modifiers_for_function_keys(); |
23a824d80de3
patch 9.0.1957: termcap options should change when setting keyprotocol
Christian Brabandt <cb@256bit.org>
parents:
33223
diff
changeset
|
1634 } |
23a824d80de3
patch 9.0.1957: termcap options should change when setting keyprotocol
Christian Brabandt <cb@256bit.org>
parents:
33223
diff
changeset
|
1635 |
23a824d80de3
patch 9.0.1957: termcap options should change when setting keyprotocol
Christian Brabandt <cb@256bit.org>
parents:
33223
diff
changeset
|
1636 /* |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1637 * Parsing of the builtin termcap entries. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1638 * Caller should check if "term" is a valid builtin terminal name. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1639 * The terminal's name is not set, as this is already done in termcapinit(). |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1640 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1641 static void |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1642 parse_builtin_tcap(char_u *term) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1643 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1644 tcap_entry_T *entries = find_builtin_term(term); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1645 if (entries != NULL) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1646 apply_builtin_tcap(term, entries, FALSE); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1647 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1648 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1649 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1650 * Set number of colors. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1651 * Store it as a number in t_colors. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1652 * Store it as a string in T_CCO (using nr_colors[]). |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1653 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1654 void |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1655 set_color_count(int nr) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1656 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1657 char_u nr_colors[20]; // string for number of colors |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1658 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1659 t_colors = nr; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1660 if (t_colors > 1) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1661 sprintf((char *)nr_colors, "%d", t_colors); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1662 else |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1663 *nr_colors = NUL; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1664 set_string_option_direct((char_u *)"t_Co", -1, nr_colors, OPT_FREE, 0); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1665 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1666 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1667 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1668 * Set the color count to "val" and redraw if it changed. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1669 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1670 static void |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1671 may_adjust_color_count(int val) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1672 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1673 if (val == t_colors) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1674 return; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1675 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1676 // Nr of colors changed, initialize highlighting and redraw everything. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1677 // This causes a redraw, which usually clears the message. Try keeping |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1678 // the message if it might work. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1679 set_keep_msg_from_hist(); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1680 set_color_count(val); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1681 init_highlight(TRUE, FALSE); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1682 #ifdef DEBUG_TERMRESPONSE |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1683 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1684 int r = redraw_asap(UPD_CLEAR); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1685 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1686 log_tr("Received t_Co, redraw_asap(): %d", r); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1687 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1688 #else |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1689 redraw_asap(UPD_CLEAR); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1690 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1691 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1692 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1693 #ifdef HAVE_TGETENT |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1694 static char *(key_names[]) = |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1695 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1696 # ifdef FEAT_TERMRESPONSE |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1697 // Do this one first, it may cause a screen redraw. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1698 "Co", |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1699 # endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1700 "ku", "kd", "kr", "kl", |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1701 "#2", "#4", "%i", "*7", |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1702 "k1", "k2", "k3", "k4", "k5", "k6", |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1703 "k7", "k8", "k9", "k;", "F1", "F2", |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1704 "%1", "&8", "kb", "kI", "kD", "kh", |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1705 "@7", "kP", "kN", "K1", "K3", "K4", "K5", "kB", |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1706 "PS", "PE", |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1707 NULL |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1708 }; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1709 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1710 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1711 #if defined(HAVE_TGETENT) || defined(FEAT_TERMGUICOLORS) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1712 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1713 * Return TRUE if "term_strings[idx]" was not set. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1714 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1715 static int |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1716 term_strings_not_set(enum SpecialKey idx) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1717 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1718 return TERM_STR(idx) == NULL || TERM_STR(idx) == empty_option; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1719 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1720 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1721 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1722 #ifdef HAVE_TGETENT |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1723 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1724 * Get the termcap entries we need with tgetstr(), tgetflag() and tgetnum(). |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1725 * "invoke_tgetent()" must have been called before. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1726 * If "*height" or "*width" are not zero then use the "li" and "col" entries to |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1727 * get their value. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1728 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1729 static void |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1730 get_term_entries(int *height, int *width) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1731 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1732 static struct { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1733 enum SpecialKey dest; // index in term_strings[] |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1734 char *name; // termcap name for string |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1735 } string_names[] = |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1736 { {KS_CE, "ce"}, {KS_AL, "al"}, {KS_CAL,"AL"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1737 {KS_DL, "dl"}, {KS_CDL,"DL"}, {KS_CS, "cs"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1738 {KS_CL, "cl"}, {KS_CD, "cd"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1739 {KS_VI, "vi"}, {KS_VE, "ve"}, {KS_MB, "mb"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1740 {KS_ME, "me"}, {KS_MR, "mr"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1741 {KS_MD, "md"}, {KS_SE, "se"}, {KS_SO, "so"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1742 {KS_CZH,"ZH"}, {KS_CZR,"ZR"}, {KS_UE, "ue"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1743 {KS_US, "us"}, {KS_UCE, "Ce"}, {KS_UCS, "Cs"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1744 {KS_USS, "Us"}, {KS_DS, "ds"}, {KS_CDS, "Ds"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1745 {KS_STE,"Te"}, {KS_STS,"Ts"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1746 {KS_CM, "cm"}, {KS_SR, "sr"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1747 {KS_CRI,"RI"}, {KS_VB, "vb"}, {KS_KS, "ks"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1748 {KS_KE, "ke"}, {KS_TI, "ti"}, {KS_TE, "te"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1749 {KS_CTI, "TI"}, {KS_CRK, "RK"}, {KS_CTE, "TE"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1750 {KS_BC, "bc"}, {KS_CSB,"Sb"}, {KS_CSF,"Sf"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1751 {KS_CAB,"AB"}, {KS_CAF,"AF"}, {KS_CAU,"AU"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1752 {KS_LE, "le"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1753 {KS_ND, "nd"}, {KS_OP, "op"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1754 {KS_CRV, "RV"}, {KS_CXM, "XM"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1755 {KS_VS, "vs"}, {KS_CVS, "VS"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1756 {KS_CIS, "IS"}, {KS_CIE, "IE"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1757 {KS_CSC, "SC"}, {KS_CEC, "EC"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1758 {KS_TS, "ts"}, {KS_FS, "fs"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1759 {KS_CWP, "WP"}, {KS_CWS, "WS"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1760 {KS_CSI, "SI"}, {KS_CEI, "EI"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1761 {KS_U7, "u7"}, {KS_RFG, "RF"}, {KS_RBG, "RB"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1762 {KS_8F, "8f"}, {KS_8B, "8b"}, {KS_8U, "8u"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1763 {KS_CBE, "BE"}, {KS_CBD, "BD"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1764 {KS_CST, "ST"}, {KS_CRT, "RT"}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1765 {KS_SSI, "Si"}, {KS_SRI, "Ri"}, |
34136
36843e079f64
patch 9.1.0030: Cannot use terminal alternate font
Christian Brabandt <cb@256bit.org>
parents:
34132
diff
changeset
|
1766 {KS_CF, "CF"}, |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1767 {(enum SpecialKey)0, NULL} |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1768 }; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1769 int i; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1770 static char_u tstrbuf[TBUFSZ]; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1771 char_u *tp = tstrbuf; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1772 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1773 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1774 * get output strings |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1775 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1776 for (i = 0; string_names[i].name != NULL; ++i) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1777 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1778 if (term_strings_not_set(string_names[i].dest)) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1779 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1780 TERM_STR(string_names[i].dest) = TGETSTR(string_names[i].name, &tp); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1781 #ifdef FEAT_EVAL |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1782 set_term_option_sctx_idx(string_names[i].name, -1); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1783 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1784 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1785 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1786 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1787 // tgetflag() returns 1 if the flag is present, 0 if not and |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1788 // possibly -1 if the flag doesn't exist. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1789 if ((T_MS == NULL || T_MS == empty_option) && tgetflag("ms") > 0) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1790 T_MS = (char_u *)"y"; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1791 if ((T_XS == NULL || T_XS == empty_option) && tgetflag("xs") > 0) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1792 T_XS = (char_u *)"y"; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1793 if ((T_XN == NULL || T_XN == empty_option) && tgetflag("xn") > 0) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1794 T_XN = (char_u *)"y"; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1795 if ((T_DB == NULL || T_DB == empty_option) && tgetflag("db") > 0) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1796 T_DB = (char_u *)"y"; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1797 if ((T_DA == NULL || T_DA == empty_option) && tgetflag("da") > 0) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1798 T_DA = (char_u *)"y"; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1799 if ((T_UT == NULL || T_UT == empty_option) && tgetflag("ut") > 0) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1800 T_UT = (char_u *)"y"; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1801 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1802 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1803 * get key codes |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1804 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1805 for (i = 0; key_names[i] != NULL; ++i) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1806 if (find_termcode((char_u *)key_names[i]) == NULL) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1807 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1808 char_u *p = TGETSTR(key_names[i], &tp); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1809 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1810 // if cursor-left == backspace, ignore it (televideo 925) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1811 if (p != NULL |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1812 && (*p != Ctrl_H |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1813 || key_names[i][0] != 'k' |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1814 || key_names[i][1] != 'l')) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1815 add_termcode((char_u *)key_names[i], p, FALSE); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1816 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1817 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1818 if (*height == 0) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1819 *height = tgetnum("li"); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1820 if (*width == 0) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1821 *width = tgetnum("co"); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1822 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1823 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1824 * Get number of colors (if not done already). |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1825 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1826 if (term_strings_not_set(KS_CCO)) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1827 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1828 set_color_count(tgetnum("Co")); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1829 #ifdef FEAT_EVAL |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1830 set_term_option_sctx_idx("Co", -1); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1831 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1832 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1833 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1834 # ifndef hpux |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1835 BC = (char *)TGETSTR("bc", &tp); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1836 UP = (char *)TGETSTR("up", &tp); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1837 char_u *p = TGETSTR("pc", &tp); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1838 if (p != NULL) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1839 PC = *p; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1840 # endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1841 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1842 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1843 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1844 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1845 * Report "term" is not found and list the ones we do know about. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1846 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1847 static void |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1848 report_term_error(char *error_msg, char_u *term) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1849 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1850 mch_errmsg("\r\n"); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1851 if (error_msg != NULL) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1852 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1853 mch_errmsg(error_msg); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1854 mch_errmsg("\r\n"); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1855 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1856 mch_errmsg("'"); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1857 mch_errmsg((char *)term); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1858 mch_errmsg(_("' not known. Available builtin terminals are:")); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1859 mch_errmsg("\r\n"); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1860 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1861 for (int i = 0; ; ++i) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1862 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1863 char *name = builtin_terminals[i].bitc_name; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1864 if (name == NULL) // end marker |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1865 break; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1866 // Do not mention the "gui" entry, the user won't need to type it. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1867 if (STRCMP(name, "gui") != 0) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1868 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1869 #ifdef HAVE_TGETENT |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1870 mch_errmsg(" builtin_"); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1871 #else |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1872 mch_errmsg(" "); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1873 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1874 mch_errmsg(name); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1875 mch_errmsg("\r\n"); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1876 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1877 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1878 // Output extra 'cmdheight' line breaks to avoid that the following error |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1879 // message overwrites the last terminal name. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1880 for (int i = 1; i < p_ch; ++i) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1881 mch_errmsg("\r\n"); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1882 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1883 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1884 static void |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1885 report_default_term(char_u *term) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1886 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1887 mch_errmsg(_("defaulting to '")); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1888 mch_errmsg((char *)term); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1889 mch_errmsg("'\r\n"); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1890 if (emsg_silent == 0 && !in_assert_fails) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1891 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1892 screen_start(); // don't know where cursor is now |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1893 out_flush(); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1894 if (!is_not_a_term()) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1895 ui_delay(2007L, TRUE); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1896 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1897 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1898 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1899 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1900 * Parse the 'keyprotocol' option, match against "term" and return the protocol |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1901 * for the first matching entry. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1902 * When "term" is NULL then compile all patterns to check for any errors. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1903 * Returns KEYPROTOCOL_FAIL if a pattern cannot be compiled. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1904 * Returns KEYPROTOCOL_NONE if there is no match. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1905 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1906 keyprot_T |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1907 match_keyprotocol(char_u *term) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1908 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1909 int len = (int)STRLEN(p_kpc) + 1; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1910 char_u *buf = alloc(len); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1911 if (buf == NULL) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1912 return KEYPROTOCOL_FAIL; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1913 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1914 keyprot_T ret = KEYPROTOCOL_FAIL; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1915 char_u *p = p_kpc; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1916 while (*p != NUL) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1917 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1918 // Isolate one comma separated item. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1919 (void)copy_option_part(&p, buf, len, ","); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1920 char_u *colon = vim_strchr(buf, ':'); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1921 if (colon == NULL || colon == buf || colon[1] == NUL) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1922 goto theend; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1923 *colon = NUL; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1924 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1925 keyprot_T prot; |
33399
95db67c7b754
patch 9.0.1958: cannot complete option values
Christian Brabandt <cb@256bit.org>
parents:
33397
diff
changeset
|
1926 // Note: Keep this in sync with p_kpc_protocol_values. |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1927 if (STRCMP(colon + 1, "none") == 0) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1928 prot = KEYPROTOCOL_NONE; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1929 else if (STRCMP(colon + 1, "mok2") == 0) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1930 prot = KEYPROTOCOL_MOK2; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1931 else if (STRCMP(colon + 1, "kitty") == 0) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1932 prot = KEYPROTOCOL_KITTY; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1933 else |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1934 goto theend; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1935 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1936 regmatch_T regmatch; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1937 CLEAR_FIELD(regmatch); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1938 regmatch.rm_ic = TRUE; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1939 regmatch.regprog = vim_regcomp(buf, RE_MAGIC); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1940 if (regmatch.regprog == NULL) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1941 goto theend; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1942 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1943 int match = term != NULL && vim_regexec(®match, term, (colnr_T)0); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1944 vim_regfree(regmatch.regprog); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1945 if (match) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1946 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1947 ret = prot; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1948 goto theend; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1949 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1950 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1951 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1952 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1953 // No match found, use "none". |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1954 ret = KEYPROTOCOL_NONE; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1955 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1956 theend: |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1957 vim_free(buf); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1958 return ret; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1959 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1960 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1961 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1962 * Set terminal options for terminal "term". |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1963 * Return OK if terminal 'term' was found in a termcap, FAIL otherwise. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1964 * |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1965 * While doing this, until ttest(), some options may be NULL, be careful. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1966 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1967 int |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1968 set_termname(char_u *term) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1969 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1970 #ifdef HAVE_TGETENT |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1971 int builtin_first = p_tbi; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1972 int try; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1973 int termcap_cleared = FALSE; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1974 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1975 int width = 0, height = 0; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1976 char *error_msg = NULL; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1977 char_u *bs_p, *del_p; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1978 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1979 // In silect mode (ex -s) we don't use the 'term' option. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1980 if (silent_mode) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1981 return OK; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1982 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1983 detected_8bit = FALSE; // reset 8-bit detection |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1984 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1985 if (term_is_builtin(term)) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1986 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1987 term += 8; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1988 #ifdef HAVE_TGETENT |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1989 builtin_first = 1; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1990 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1991 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1992 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1993 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1994 * If HAVE_TGETENT is not defined, only the builtin termcap is used, otherwise: |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1995 * If builtin_first is TRUE: |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1996 * 0. try builtin termcap |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1997 * 1. try external termcap |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1998 * 2. if both fail default to a builtin terminal |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
1999 * If builtin_first is FALSE: |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2000 * 1. try external termcap |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2001 * 2. try builtin termcap, if both fail default to a builtin terminal |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2002 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2003 #ifdef HAVE_TGETENT |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2004 for (try = builtin_first ? 0 : 1; try < 3; ++try) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2005 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2006 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2007 * Use external termcap |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2008 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2009 if (try == 1) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2010 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2011 char_u tbuf[TBUFSZ]; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2012 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2013 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2014 * If the external termcap does not have a matching entry, try the |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2015 * builtin ones. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2016 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2017 if ((error_msg = invoke_tgetent(tbuf, term)) == NULL) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2018 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2019 if (!termcap_cleared) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2020 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2021 clear_termoptions(); // clear old options |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2022 termcap_cleared = TRUE; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2023 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2024 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2025 get_term_entries(&height, &width); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2026 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2027 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2028 else // try == 0 || try == 2 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2029 #endif // HAVE_TGETENT |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2030 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2031 * Use builtin termcap |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2032 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2033 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2034 #ifdef HAVE_TGETENT |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2035 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2036 * If builtin termcap was already used, there is no need to search |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2037 * for the builtin termcap again, quit now. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2038 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2039 if (try == 2 && builtin_first && termcap_cleared) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2040 break; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2041 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2042 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2043 * Search for 'term' in builtin_terminals[]. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2044 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2045 tcap_entry_T *termp = find_builtin_term(term); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2046 if (termp == NULL) // did not find it |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2047 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2048 #ifdef HAVE_TGETENT |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2049 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2050 * If try == 0, first try the external termcap. If that is not |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2051 * found we'll get back here with try == 2. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2052 * If termcap_cleared is set we used the external termcap, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2053 * don't complain about not finding the term in the builtin |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2054 * termcap. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2055 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2056 if (try == 0) // try external one |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2057 continue; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2058 if (termcap_cleared) // found in external termcap |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2059 break; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2060 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2061 report_term_error(error_msg, term); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2062 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2063 // when user typed :set term=xxx, quit here |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2064 if (starting != NO_SCREEN) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2065 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2066 screen_start(); // don't know where cursor is now |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2067 wait_return(TRUE); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2068 return FAIL; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2069 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2070 term = DEFAULT_TERM; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2071 report_default_term(term); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2072 set_string_option_direct((char_u *)"term", -1, term, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2073 OPT_FREE, 0); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2074 display_errors(); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2075 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2076 out_flush(); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2077 #ifdef HAVE_TGETENT |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2078 if (!termcap_cleared) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2079 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2080 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2081 clear_termoptions(); // clear old options |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2082 #ifdef HAVE_TGETENT |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2083 termcap_cleared = TRUE; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2084 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2085 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2086 parse_builtin_tcap(term); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2087 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2088 #ifdef FEAT_GUI |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2089 if (term_is_gui(term)) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2090 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2091 out_flush(); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2092 gui_init(); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2093 // If starting the GUI failed, don't do any of the other |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2094 // things for this terminal |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2095 if (!gui.in_use) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2096 return FAIL; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2097 # ifdef HAVE_TGETENT |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2098 break; // don't try using external termcap |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2099 # endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2100 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2101 #endif // FEAT_GUI |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2102 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2103 #ifdef HAVE_TGETENT |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2104 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2105 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2106 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2107 #ifdef FEAT_GUI |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2108 if (!gui.in_use) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2109 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2110 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2111 // Use the 'keyprotocol' option to adjust the t_TE and t_TI |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2112 // termcap entries if there is an entry matching "term". |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2113 keyprot_T kpc = match_keyprotocol(term); |
33397
23a824d80de3
patch 9.0.1957: termcap options should change when setting keyprotocol
Christian Brabandt <cb@256bit.org>
parents:
33223
diff
changeset
|
2114 apply_keyprotocol(term, kpc); |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2115 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2116 #ifdef FEAT_TERMGUICOLORS |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2117 // There is no good way to detect that the terminal supports RGB |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2118 // colors. Since these termcap entries are non-standard anyway and |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2119 // only used when the user sets 'termguicolors' we might as well add |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2120 // them. But not when one of them was already set. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2121 if (term_strings_not_set(KS_8F) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2122 && term_strings_not_set(KS_8B) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2123 && term_strings_not_set(KS_8U)) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2124 apply_builtin_tcap(term, builtin_rgb, TRUE); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2125 #endif |
34140
adc185c5ca29
patch 9.1.0031: Link Error on Windows
Christian Brabandt <cb@256bit.org>
parents:
34136
diff
changeset
|
2126 #ifdef HAVE_TGETENT |
34136
36843e079f64
patch 9.1.0030: Cannot use terminal alternate font
Christian Brabandt <cb@256bit.org>
parents:
34132
diff
changeset
|
2127 if (term_strings_not_set(KS_CF)) |
36843e079f64
patch 9.1.0030: Cannot use terminal alternate font
Christian Brabandt <cb@256bit.org>
parents:
34132
diff
changeset
|
2128 apply_builtin_tcap(term, special_term, TRUE); |
34140
adc185c5ca29
patch 9.1.0031: Link Error on Windows
Christian Brabandt <cb@256bit.org>
parents:
34136
diff
changeset
|
2129 #endif |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2130 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2131 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2132 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2133 * special: There is no info in the termcap about whether the cursor |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2134 * positioning is relative to the start of the screen or to the start of the |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2135 * scrolling region. We just guess here. Only msdos pcterm is known to do it |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2136 * relative. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2137 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2138 if (STRCMP(term, "pcterm") == 0) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2139 T_CCS = (char_u *)"yes"; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2140 else |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2141 T_CCS = empty_option; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2142 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2143 // Special case: "kitty" may not have a "RV" entry in terminfo, but we need |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2144 // to request the version for several other things to work. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2145 if (strstr((char *)term, "kitty") != NULL |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2146 && (T_CRV == NULL || *T_CRV == NUL)) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2147 T_CRV = (char_u *)"\033[>c"; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2148 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2149 #ifdef UNIX |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2150 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2151 * Any "stty" settings override the default for t_kb from the termcap. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2152 * This is in os_unix.c, because it depends a lot on the version of unix that |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2153 * is being used. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2154 * Don't do this when the GUI is active, it uses "t_kb" and "t_kD" directly. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2155 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2156 # ifdef FEAT_GUI |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2157 if (!gui.in_use) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2158 # endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2159 get_stty(); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2160 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2161 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2162 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2163 * If the termcap has no entry for 'bs' and/or 'del' and the ioctl() also |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2164 * didn't work, use the default CTRL-H |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2165 * The default for t_kD is DEL, unless t_kb is DEL. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2166 * The vim_strsave'd strings are probably lost forever, well it's only two |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2167 * bytes. Don't do this when the GUI is active, it uses "t_kb" and "t_kD" |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2168 * directly. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2169 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2170 #ifdef FEAT_GUI |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2171 if (!gui.in_use) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2172 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2173 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2174 bs_p = find_termcode((char_u *)"kb"); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2175 del_p = find_termcode((char_u *)"kD"); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2176 if (bs_p == NULL || *bs_p == NUL) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2177 add_termcode((char_u *)"kb", (bs_p = (char_u *)CTRL_H_STR), FALSE); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2178 if ((del_p == NULL || *del_p == NUL) && |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2179 (bs_p == NULL || *bs_p != DEL)) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2180 add_termcode((char_u *)"kD", (char_u *)DEL_STR, FALSE); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2181 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2182 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2183 #if defined(UNIX) || defined(VMS) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2184 term_is_xterm = vim_is_xterm(term); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2185 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2186 #ifdef FEAT_TERMRESPONSE |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2187 // Reset terminal properties that are set based on the termresponse, which |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2188 // will be sent out soon. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2189 init_term_props(FALSE); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2190 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2191 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2192 #if defined(UNIX) || defined(VMS) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2193 // If the first number in t_XM is 1006 then the terminal will support SGR |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2194 // mouse reporting. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2195 int did_set_ttym = FALSE; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2196 if (T_CXM != NULL && *T_CXM != NUL && !option_was_set((char_u *)"ttym")) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2197 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2198 char_u *p = T_CXM; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2199 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2200 while (*p != NUL && !VIM_ISDIGIT(*p)) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2201 ++p; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2202 if (getdigits(&p) == 1006) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2203 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2204 did_set_ttym = TRUE; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2205 set_option_value_give_err((char_u *)"ttym", 0L, (char_u *)"sgr", 0); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2206 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2207 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2208 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2209 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2210 * For Unix, set the 'ttymouse' option to the type of mouse to be used. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2211 * The termcode for the mouse is added as a side effect in option.c. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2212 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2213 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2214 char_u *p = (char_u *)""; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2215 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2216 # ifdef FEAT_MOUSE_XTERM |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2217 if (use_xterm_like_mouse(term)) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2218 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2219 if (use_xterm_mouse()) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2220 p = NULL; // keep existing value, might be "xterm2" |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2221 else |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2222 p = (char_u *)"xterm"; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2223 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2224 # endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2225 if (p != NULL && !did_set_ttym) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2226 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2227 set_option_value_give_err((char_u *)"ttym", 0L, p, 0); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2228 // Reset the WAS_SET flag, 'ttymouse' can be set to "sgr" or |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2229 // "xterm2" in check_termcode(). |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2230 reset_option_was_set((char_u *)"ttym"); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2231 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2232 if (p == NULL |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2233 # ifdef FEAT_GUI |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2234 || gui.in_use |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2235 # endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2236 ) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2237 check_mouse_termcode(); // set mouse termcode anyway |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2238 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2239 #else |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2240 set_mouse_termcode(KS_MOUSE, (char_u *)"\233M"); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2241 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2242 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2243 #ifdef FEAT_MOUSE_XTERM |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2244 // Focus reporting is supported by xterm compatible terminals and tmux. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2245 // We hard-code the received escape sequences here. There are the terminfo |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2246 // entries kxIN and kxOUT, but they are rarely used and do hot have a |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2247 // two-letter termcap name. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2248 // This used to be done only for xterm-like terminals, but some others also |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2249 // may produce these codes. Always recognize them, as the chance of them |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2250 // being used for something else is very small. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2251 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2252 char_u name[3]; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2253 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2254 // handle focus in event |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2255 name[0] = KS_EXTRA; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2256 name[1] = KE_FOCUSGAINED; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2257 name[2] = NUL; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2258 add_termcode(name, (char_u *)"\033[I", FALSE); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2259 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2260 // handle focus out event |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2261 name[1] = KE_FOCUSLOST; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2262 add_termcode(name, (char_u *)"\033[O", FALSE); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2263 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2264 need_gather = TRUE; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2265 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2266 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2267 #if (defined(UNIX) || defined(VMS)) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2268 // First time after setting 'term' a focus event is always reported. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2269 focus_state = MAYBE; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2270 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2271 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2272 #ifdef USE_TERM_CONSOLE |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2273 // DEFAULT_TERM indicates that it is the machine console. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2274 if (STRCMP(term, DEFAULT_TERM) != 0) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2275 term_console = FALSE; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2276 else |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2277 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2278 term_console = TRUE; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2279 # ifdef AMIGA |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2280 win_resize_on(); // enable window resizing reports |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2281 # endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2282 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2283 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2284 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2285 ttest(TRUE); // make sure we have a valid set of terminal codes |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2286 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2287 full_screen = TRUE; // we can use termcap codes from now on |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2288 set_term_defaults(); // use current values as defaults |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2289 #ifdef FEAT_TERMRESPONSE |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2290 LOG_TR(("setting crv_status to STATUS_GET")); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2291 crv_status.tr_progress = STATUS_GET; // Get terminal version later |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2292 write_t_8u_state = FALSE; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2293 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2294 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2295 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2296 * Initialize the terminal with the appropriate termcap codes. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2297 * Set the mouse and window title if possible. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2298 * Don't do this when starting, need to parse the .vimrc first, because it |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2299 * may redefine t_TI etc. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2300 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2301 if (starting != NO_SCREEN) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2302 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2303 starttermcap(); // may change terminal mode |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2304 setmouse(); // may start using the mouse |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2305 maketitle(); // may display window title |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2306 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2307 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2308 // display initial screen after ttest() checking. jw. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2309 if (width <= 0 || height <= 0) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2310 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2311 // termcap failed to report size |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2312 // set defaults, in case ui_get_shellsize() also fails |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2313 width = 80; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2314 #if defined(MSWIN) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2315 height = 25; // console is often 25 lines |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2316 #else |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2317 height = 24; // most terminals are 24 lines |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2318 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2319 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2320 set_shellsize(width, height, FALSE); // may change Rows |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2321 if (starting != NO_SCREEN) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2322 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2323 if (scroll_region) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2324 scroll_region_reset(); // In case Rows changed |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2325 check_map_keycodes(); // check mappings for terminal codes used |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2326 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2327 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2328 buf_T *buf; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2329 aco_save_T aco; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2330 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2331 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2332 * Execute the TermChanged autocommands for each buffer that is |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2333 * loaded. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2334 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2335 FOR_ALL_BUFFERS(buf) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2336 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2337 if (curbuf->b_ml.ml_mfp != NULL) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2338 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2339 aucmd_prepbuf(&aco, buf); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2340 if (curbuf == buf) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2341 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2342 apply_autocmds(EVENT_TERMCHANGED, NULL, NULL, FALSE, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2343 curbuf); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2344 // restore curwin/curbuf and a few other things |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2345 aucmd_restbuf(&aco); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2346 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2347 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2348 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2349 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2350 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2351 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2352 #ifdef FEAT_TERMRESPONSE |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2353 may_req_termresponse(); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2354 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2355 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2356 return OK; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2357 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2358 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2359 #if defined(EXITFREE) || defined(PROTO) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2360 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2361 # ifdef HAVE_DEL_CURTERM |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2362 # include <term.h> // declares cur_term |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2363 # endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2364 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2365 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2366 * If supported, delete "cur_term", which caches terminal related entries. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2367 * Avoids that valgrind reports possibly lost memory. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2368 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2369 void |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2370 free_cur_term(void) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2371 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2372 # ifdef HAVE_DEL_CURTERM |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2373 if (cur_term) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2374 del_curterm(cur_term); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2375 # endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2376 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2377 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2378 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2379 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2380 #ifdef HAVE_TGETENT |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2381 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2382 * Call tgetent() |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2383 * Return error message if it fails, NULL if it's OK. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2384 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2385 static char * |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2386 invoke_tgetent(char_u *tbuf, char_u *term) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2387 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2388 int i; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2389 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2390 // Note: Valgrind may report a leak here, because the library keeps one |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2391 // buffer around that we can't ever free. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2392 i = TGETENT(tbuf, term); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2393 if (i < 0 // -1 is always an error |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2394 # ifdef TGETENT_ZERO_ERR |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2395 || i == 0 // sometimes zero is also an error |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2396 # endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2397 ) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2398 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2399 // On FreeBSD tputs() gets a SEGV after a tgetent() which fails. Call |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2400 // tgetent() with the always existing "dumb" entry to avoid a crash or |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2401 // hang. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2402 (void)TGETENT(tbuf, "dumb"); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2403 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2404 if (i < 0) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2405 # ifdef TGETENT_ZERO_ERR |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2406 return _(e_cannot_open_termcap_file); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2407 if (i == 0) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2408 # endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2409 #ifdef TERMINFO |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2410 return _(e_terminal_entry_not_found_in_terminfo); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2411 #else |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2412 return _(e_terminal_entry_not_found_in_termcap); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2413 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2414 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2415 return NULL; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2416 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2417 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2418 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2419 * Some versions of tgetstr() have been reported to return -1 instead of NULL. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2420 * Fix that here. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2421 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2422 static char_u * |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2423 vim_tgetstr(char *s, char_u **pp) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2424 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2425 char *p; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2426 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2427 p = tgetstr(s, (char **)pp); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2428 if (p == (char *)-1) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2429 p = NULL; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2430 return (char_u *)p; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2431 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2432 #endif // HAVE_TGETENT |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2433 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2434 #if defined(HAVE_TGETENT) && (defined(UNIX) || defined(VMS) || defined(MACOS_X)) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2435 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2436 * Get Columns and Rows from the termcap. Used after a window signal if the |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2437 * ioctl() fails. It doesn't make sense to call tgetent each time if the "co" |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2438 * and "li" entries never change. But on some systems this works. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2439 * Errors while getting the entries are ignored. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2440 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2441 void |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2442 getlinecol( |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2443 long *cp, // pointer to columns |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2444 long *rp) // pointer to rows |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2445 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2446 char_u tbuf[TBUFSZ]; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2447 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2448 if (T_NAME == NULL || *T_NAME == NUL |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2449 || invoke_tgetent(tbuf, T_NAME) != NULL) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2450 return; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2451 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2452 if (*cp == 0) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2453 *cp = tgetnum("co"); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2454 if (*rp == 0) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2455 *rp = tgetnum("li"); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2456 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2457 #endif // defined(HAVE_TGETENT) && defined(UNIX) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2458 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2459 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2460 * Get a string entry from the termcap and add it to the list of termcodes. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2461 * Used for <t_xx> special keys. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2462 * Give an error message for failure when not sourcing. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2463 * If force given, replace an existing entry. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2464 * Return FAIL if the entry was not found, OK if the entry was added. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2465 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2466 int |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2467 add_termcap_entry(char_u *name, int force) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2468 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2469 char_u *term; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2470 int key; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2471 #ifdef HAVE_TGETENT |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2472 char_u *string; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2473 int i; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2474 int builtin_first; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2475 char_u tbuf[TBUFSZ]; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2476 char_u tstrbuf[TBUFSZ]; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2477 char_u *tp = tstrbuf; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2478 char *error_msg = NULL; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2479 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2480 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2481 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2482 * If the GUI is running or will start in a moment, we only support the keys |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2483 * that the GUI can produce. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2484 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2485 #ifdef FEAT_GUI |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2486 if (gui.in_use || gui.starting) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2487 return gui_mch_haskey(name); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2488 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2489 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2490 if (!force && find_termcode(name) != NULL) // it's already there |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2491 return OK; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2492 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2493 term = T_NAME; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2494 if (term == NULL || *term == NUL) // 'term' not defined yet |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2495 return FAIL; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2496 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2497 if (term_is_builtin(term)) // name starts with "builtin_" |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2498 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2499 term += 8; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2500 #ifdef HAVE_TGETENT |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2501 builtin_first = TRUE; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2502 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2503 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2504 #ifdef HAVE_TGETENT |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2505 else |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2506 builtin_first = p_tbi; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2507 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2508 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2509 #ifdef HAVE_TGETENT |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2510 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2511 * We can get the entry from the builtin termcap and from the external one. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2512 * If 'ttybuiltin' is on or the terminal name starts with "builtin_", try |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2513 * builtin termcap first. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2514 * If 'ttybuiltin' is off, try external termcap first. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2515 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2516 for (i = 0; i < 2; ++i) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2517 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2518 if ((!builtin_first) == i) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2519 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2520 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2521 * Search in builtin termcaps |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2522 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2523 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2524 tcap_entry_T *termp = find_builtin_term(term); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2525 if (termp != NULL) // found it |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2526 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2527 key = TERMCAP2KEY(name[0], name[1]); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2528 ++termp; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2529 while (termp->bt_entry != (int)KS_NAME) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2530 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2531 if ((int)termp->bt_entry == key) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2532 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2533 add_termcode(name, (char_u *)termp->bt_string, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2534 term_is_8bit(term)); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2535 return OK; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2536 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2537 ++termp; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2538 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2539 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2540 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2541 #ifdef HAVE_TGETENT |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2542 else |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2543 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2544 * Search in external termcap |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2545 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2546 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2547 error_msg = invoke_tgetent(tbuf, term); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2548 if (error_msg == NULL) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2549 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2550 string = TGETSTR((char *)name, &tp); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2551 if (string != NULL && *string != NUL) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2552 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2553 add_termcode(name, string, FALSE); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2554 return OK; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2555 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2556 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2557 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2558 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2559 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2560 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2561 if (SOURCING_NAME == NULL) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2562 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2563 #ifdef HAVE_TGETENT |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2564 if (error_msg != NULL) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2565 emsg(error_msg); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2566 else |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2567 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2568 semsg(_(e_no_str_entry_in_termcap), name); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2569 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2570 return FAIL; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2571 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2572 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2573 static int |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2574 term_is_builtin(char_u *name) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2575 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2576 return (STRNCMP(name, "builtin_", (size_t)8) == 0); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2577 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2578 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2579 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2580 * Return TRUE if terminal "name" uses CSI instead of <Esc>[. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2581 * Assume that the terminal is using 8-bit controls when the name contains |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2582 * "8bit", like in "xterm-8bit". |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2583 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2584 int |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2585 term_is_8bit(char_u *name) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2586 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2587 return (detected_8bit || strstr((char *)name, "8bit") != NULL); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2588 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2589 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2590 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2591 * Translate terminal control chars from 7-bit to 8-bit: |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2592 * <Esc>[ -> CSI <M_C_[> |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2593 * <Esc>] -> OSC <M-C-]> |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2594 * <Esc>O -> <M-C-O> |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2595 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2596 static int |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2597 term_7to8bit(char_u *p) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2598 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2599 if (*p != ESC) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2600 return 0; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2601 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2602 if (p[1] == '[') |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2603 return CSI; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2604 else if (p[1] == ']') |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2605 return OSC; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2606 else if (p[1] == 'O') |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2607 return 0x8f; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2608 return 0; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2609 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2610 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2611 #if defined(FEAT_GUI) || defined(PROTO) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2612 int |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2613 term_is_gui(char_u *name) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2614 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2615 return (STRCMP(name, "builtin_gui") == 0 || STRCMP(name, "gui") == 0); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2616 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2617 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2618 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2619 #if !defined(HAVE_TGETENT) || defined(AMIGA) || defined(PROTO) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2620 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2621 char_u * |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2622 tltoa(unsigned long i) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2623 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2624 static char_u buf[16]; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2625 char_u *p; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2626 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2627 p = buf + 15; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2628 *p = '\0'; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2629 do |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2630 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2631 --p; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2632 *p = (char_u) (i % 10 + '0'); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2633 i /= 10; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2634 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2635 while (i > 0 && p > buf); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2636 return p; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2637 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2638 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2639 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2640 #ifndef HAVE_TGETENT |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2641 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2642 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2643 * minimal tgoto() implementation. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2644 * no padding and we only parse for %i %d and %+char |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2645 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2646 static char * |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2647 tgoto(char *cm, int x, int y) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2648 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2649 static char buf[30]; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2650 char *p, *s, *e; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2651 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2652 if (!cm) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2653 return "OOPS"; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2654 e = buf + 29; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2655 for (s = buf; s < e && *cm; cm++) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2656 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2657 if (*cm != '%') |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2658 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2659 *s++ = *cm; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2660 continue; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2661 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2662 switch (*++cm) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2663 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2664 case 'd': |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2665 p = (char *)tltoa((unsigned long)y); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2666 y = x; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2667 while (*p) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2668 *s++ = *p++; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2669 break; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2670 case 'i': |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2671 x++; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2672 y++; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2673 break; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2674 case '+': |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2675 *s++ = (char)(*++cm + y); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2676 y = x; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2677 break; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2678 case '%': |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2679 *s++ = *cm; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2680 break; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2681 default: |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2682 return "OOPS"; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2683 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2684 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2685 *s = '\0'; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2686 return buf; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2687 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2688 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2689 #endif // HAVE_TGETENT |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2690 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2691 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2692 * Set the terminal name and initialize the terminal options. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2693 * If "name" is NULL or empty, get the terminal name from the environment. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2694 * If that fails, use the default terminal name. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2695 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2696 void |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2697 termcapinit(char_u *name) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2698 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2699 char_u *term = name; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2700 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2701 if (term != NULL && *term == NUL) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2702 term = NULL; // empty name is equal to no name |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2703 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2704 #ifndef MSWIN |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2705 if (term == NULL) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2706 term = mch_getenv((char_u *)"TERM"); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2707 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2708 if (term == NULL || *term == NUL) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2709 term = DEFAULT_TERM; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2710 set_string_option_direct((char_u *)"term", -1, term, OPT_FREE, 0); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2711 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2712 // Set the default terminal name. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2713 set_string_default("term", term); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2714 set_string_default("ttytype", term); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2715 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2716 // Avoid using "term" here, because the next mch_getenv() may overwrite it. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2717 set_termname(T_NAME != NULL ? T_NAME : term); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2718 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2719 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2720 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2721 * The number of calls to ui_write is reduced by using "out_buf". |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2722 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2723 #define OUT_SIZE 2047 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2724 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2725 // add one to allow mch_write() in os_win32.c to append a NUL |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2726 static char_u out_buf[OUT_SIZE + 1]; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2727 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2728 static int out_pos = 0; // number of chars in out_buf |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2729 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2730 // Since the maximum number of SGR parameters shown as a normal value range is |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2731 // 16, the escape sequence length can be 4 * 16 + lead + tail. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2732 #define MAX_ESC_SEQ_LEN 80 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2733 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2734 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2735 * out_flush(): flush the output buffer |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2736 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2737 void |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2738 out_flush(void) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2739 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2740 int len; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2741 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2742 if (out_pos == 0) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2743 return; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2744 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2745 // set out_pos to 0 before ui_write, to avoid recursiveness |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2746 len = out_pos; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2747 out_pos = 0; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2748 ui_write(out_buf, len, FALSE); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2749 #ifdef FEAT_EVAL |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2750 if (ch_log_output != FALSE) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2751 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2752 out_buf[len] = NUL; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2753 ch_log(NULL, "raw %s output: \"%s\"", |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2754 # ifdef FEAT_GUI |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2755 (gui.in_use && !gui.dying && !gui.starting) ? "GUI" : |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2756 # endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2757 "terminal", |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2758 out_buf); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2759 if (ch_log_output == TRUE) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2760 ch_log_output = FALSE; // only log once |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2761 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2762 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2763 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2764 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2765 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2766 * out_flush_cursor(): flush the output buffer and redraw the cursor. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2767 * Does not flush recursively in the GUI to avoid slow drawing. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2768 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2769 void |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2770 out_flush_cursor( |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2771 int force UNUSED, // when TRUE, update cursor even when not moved |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2772 int clear_selection UNUSED) // clear selection under cursor |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2773 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2774 mch_disable_flush(); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2775 out_flush(); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2776 mch_enable_flush(); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2777 #ifdef FEAT_GUI |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2778 if (gui.in_use) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2779 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2780 gui_update_cursor(force, clear_selection); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2781 gui_may_flush(); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2782 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2783 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2784 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2785 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2786 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2787 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2788 * Sometimes a byte out of a multi-byte character is written with out_char(). |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2789 * To avoid flushing half of the character, call this function first. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2790 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2791 void |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2792 out_flush_check(void) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2793 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2794 if (enc_dbcs != 0 && out_pos >= OUT_SIZE - MB_MAXBYTES) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2795 out_flush(); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2796 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2797 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2798 #ifdef FEAT_GUI |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2799 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2800 * out_trash(): Throw away the contents of the output buffer |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2801 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2802 void |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2803 out_trash(void) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2804 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2805 out_pos = 0; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2806 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2807 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2808 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2809 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2810 * out_char(c): put a byte into the output buffer. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2811 * Flush it if it becomes full. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2812 * This should not be used for outputting text on the screen (use functions |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2813 * like msg_puts() and screen_putchar() for that). |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2814 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2815 void |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2816 out_char(unsigned c) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2817 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2818 #if defined(UNIX) || defined(VMS) || defined(AMIGA) || defined(MACOS_X) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2819 if (c == '\n') // turn LF into CR-LF (CRMOD doesn't seem to do this) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2820 out_char('\r'); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2821 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2822 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2823 out_buf[out_pos++] = c; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2824 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2825 // For testing we flush each time. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2826 if (out_pos >= OUT_SIZE || p_wd) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2827 out_flush(); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2828 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2829 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2830 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2831 * Output "c" like out_char(), but don't flush when p_wd is set. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2832 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2833 static int |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2834 out_char_nf(int c) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2835 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2836 out_buf[out_pos++] = (unsigned)c; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2837 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2838 if (out_pos >= OUT_SIZE) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2839 out_flush(); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2840 return (unsigned)c; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2841 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2842 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2843 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2844 * A never-padding out_str(). |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2845 * Use this whenever you don't want to run the string through tputs(). |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2846 * tputs() above is harmless, but tputs() from the termcap library |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2847 * is likely to strip off leading digits, that it mistakes for padding |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2848 * information, and "%i", "%d", etc. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2849 * This should only be used for writing terminal codes, not for outputting |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2850 * normal text (use functions like msg_puts() and screen_putchar() for that). |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2851 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2852 void |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2853 out_str_nf(char_u *s) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2854 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2855 // avoid terminal strings being split up |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2856 if (out_pos > OUT_SIZE - MAX_ESC_SEQ_LEN) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2857 out_flush(); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2858 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2859 for (char_u *p = s; *p != NUL; ++p) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2860 out_char_nf(*p); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2861 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2862 // For testing we write one string at a time. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2863 if (p_wd) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2864 out_flush(); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2865 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2866 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2867 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2868 * A conditional-flushing out_str, mainly for visualbell. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2869 * Handles a delay internally, because termlib may not respect the delay or do |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2870 * it at the wrong time. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2871 * Note: Only for terminal strings. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2872 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2873 void |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2874 out_str_cf(char_u *s) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2875 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2876 if (s == NULL || *s == NUL) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2877 return; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2878 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2879 #ifdef HAVE_TGETENT |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2880 char_u *p; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2881 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2882 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2883 #ifdef FEAT_GUI |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2884 // Don't use tputs() when GUI is used, ncurses crashes. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2885 if (gui.in_use) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2886 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2887 out_str_nf(s); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2888 return; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2889 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2890 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2891 if (out_pos > OUT_SIZE - MAX_ESC_SEQ_LEN) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2892 out_flush(); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2893 #ifdef HAVE_TGETENT |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2894 for (p = s; *s; ++s) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2895 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2896 // flush just before delay command |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2897 if (*s == '$' && *(s + 1) == '<') |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2898 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2899 char_u save_c = *s; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2900 int duration = atoi((char *)s + 2); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2901 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2902 *s = NUL; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2903 tputs((char *)p, 1, TPUTSFUNCAST out_char_nf); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2904 *s = save_c; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2905 out_flush(); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2906 # ifdef ELAPSED_FUNC |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2907 // Only sleep here if we can limit this happening in |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2908 // vim_beep(). |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2909 p = vim_strchr(s, '>'); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2910 if (p == NULL || duration <= 0) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2911 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2912 // can't parse the time, don't sleep here |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2913 p = s; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2914 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2915 else |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2916 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2917 ++p; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2918 do_sleep(duration, FALSE); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2919 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2920 # else |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2921 // Rely on the terminal library to sleep. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2922 p = s; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2923 # endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2924 break; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2925 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2926 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2927 tputs((char *)p, 1, TPUTSFUNCAST out_char_nf); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2928 #else |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2929 while (*s) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2930 out_char_nf(*s++); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2931 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2932 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2933 // For testing we write one string at a time. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2934 if (p_wd) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2935 out_flush(); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2936 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2937 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2938 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2939 * out_str(s): Put a character string a byte at a time into the output buffer. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2940 * If HAVE_TGETENT is defined use tputs(), the termcap parser. (jw) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2941 * This should only be used for writing terminal codes, not for outputting |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2942 * normal text (use functions like msg_puts() and screen_putchar() for that). |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2943 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2944 void |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2945 out_str(char_u *s) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2946 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2947 if (s == NULL || *s == NUL) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2948 return; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2949 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2950 #ifdef FEAT_GUI |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2951 // Don't use tputs() when GUI is used, ncurses crashes. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2952 if (gui.in_use) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2953 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2954 out_str_nf(s); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2955 return; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2956 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2957 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2958 // avoid terminal strings being split up |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2959 if (out_pos > OUT_SIZE - MAX_ESC_SEQ_LEN) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2960 out_flush(); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2961 #ifdef HAVE_TGETENT |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2962 tputs((char *)s, 1, TPUTSFUNCAST out_char_nf); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2963 #else |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2964 while (*s) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2965 out_char_nf(*s++); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2966 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2967 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2968 // For testing we write one string at a time. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2969 if (p_wd) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2970 out_flush(); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2971 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2972 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2973 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2974 * cursor positioning using termcap parser. (jw) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2975 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2976 void |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2977 term_windgoto(int row, int col) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2978 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2979 OUT_STR(tgoto((char *)T_CM, col, row)); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2980 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2981 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2982 void |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2983 term_cursor_right(int i) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2984 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2985 OUT_STR(tgoto((char *)T_CRI, 0, i)); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2986 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2987 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2988 void |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2989 term_append_lines(int line_count) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2990 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2991 OUT_STR(tgoto((char *)T_CAL, 0, line_count)); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2992 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2993 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2994 void |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2995 term_delete_lines(int line_count) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2996 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2997 OUT_STR(tgoto((char *)T_CDL, 0, line_count)); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2998 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
2999 |
33888
cb88e5c589d0
patch 9.0.2153: no support to build on OpenVMS
Christian Brabandt <cb@256bit.org>
parents:
33399
diff
changeset
|
3000 #if defined(UNIX) || defined(VMS) || defined(PROTO) |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3001 void |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3002 term_enable_mouse(int enable) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3003 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3004 int on = enable ? 1 : 0; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3005 OUT_STR(tgoto((char *)T_CXM, 0, on)); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3006 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3007 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3008 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3009 #if defined(HAVE_TGETENT) || defined(PROTO) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3010 void |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3011 term_set_winpos(int x, int y) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3012 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3013 // Can't handle a negative value here |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3014 if (x < 0) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3015 x = 0; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3016 if (y < 0) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3017 y = 0; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3018 OUT_STR(tgoto((char *)T_CWP, y, x)); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3019 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3020 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3021 # if defined(FEAT_TERMRESPONSE) || defined(PROTO) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3022 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3023 * Return TRUE if we can request the terminal for a response. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3024 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3025 static int |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3026 can_get_termresponse(void) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3027 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3028 return cur_tmode == TMODE_RAW |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3029 && termcap_active |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3030 # ifdef UNIX |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3031 && (is_not_a_term() || (isatty(1) && isatty(read_cmd_fd))) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3032 # endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3033 && p_ek; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3034 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3035 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3036 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3037 * Set "status" to STATUS_SENT. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3038 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3039 static void |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3040 termrequest_sent(termrequest_T *status) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3041 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3042 status->tr_progress = STATUS_SENT; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3043 status->tr_start = time(NULL); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3044 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3045 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3046 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3047 * Return TRUE if any of the requests are in STATUS_SENT. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3048 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3049 static int |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3050 termrequest_any_pending(void) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3051 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3052 int i; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3053 time_t now = time(NULL); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3054 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3055 for (i = 0; all_termrequests[i] != NULL; ++i) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3056 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3057 if (all_termrequests[i]->tr_progress == STATUS_SENT) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3058 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3059 if (all_termrequests[i]->tr_start > 0 && now > 0 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3060 && all_termrequests[i]->tr_start + 2 < now) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3061 // Sent the request more than 2 seconds ago and didn't get a |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3062 // response, assume it failed. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3063 all_termrequests[i]->tr_progress = STATUS_FAIL; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3064 else |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3065 return TRUE; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3066 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3067 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3068 return FALSE; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3069 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3070 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3071 static int winpos_x = -1; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3072 static int winpos_y = -1; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3073 static int did_request_winpos = 0; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3074 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3075 # if defined(FEAT_EVAL) || defined(FEAT_TERMINAL) || defined(PROTO) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3076 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3077 * Try getting the Vim window position from the terminal. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3078 * Returns OK or FAIL. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3079 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3080 int |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3081 term_get_winpos(int *x, int *y, varnumber_T timeout) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3082 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3083 int count = 0; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3084 int prev_winpos_x = winpos_x; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3085 int prev_winpos_y = winpos_y; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3086 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3087 if (*T_CGP == NUL || !can_get_termresponse()) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3088 return FAIL; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3089 winpos_x = -1; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3090 winpos_y = -1; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3091 ++did_request_winpos; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3092 termrequest_sent(&winpos_status); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3093 OUT_STR(T_CGP); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3094 out_flush(); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3095 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3096 // Try reading the result for "timeout" msec. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3097 while (count++ <= timeout / 10 && !got_int) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3098 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3099 (void)vpeekc_nomap(); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3100 if (winpos_x >= 0 && winpos_y >= 0) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3101 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3102 *x = winpos_x; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3103 *y = winpos_y; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3104 return OK; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3105 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3106 ui_delay(10L, FALSE); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3107 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3108 // Do not reset "did_request_winpos", if we timed out the response might |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3109 // still come later and we must consume it. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3110 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3111 winpos_x = prev_winpos_x; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3112 winpos_y = prev_winpos_y; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3113 if (timeout < 10 && prev_winpos_y >= 0 && prev_winpos_x >= 0) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3114 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3115 // Polling: return previous values if we have them. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3116 *x = winpos_x; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3117 *y = winpos_y; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3118 return OK; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3119 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3120 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3121 return FALSE; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3122 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3123 # endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3124 # endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3125 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3126 void |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3127 term_set_winsize(int height, int width) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3128 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3129 OUT_STR(tgoto((char *)T_CWS, width, height)); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3130 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3131 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3132 |
34136
36843e079f64
patch 9.1.0030: Cannot use terminal alternate font
Christian Brabandt <cb@256bit.org>
parents:
34132
diff
changeset
|
3133 void |
36843e079f64
patch 9.1.0030: Cannot use terminal alternate font
Christian Brabandt <cb@256bit.org>
parents:
34132
diff
changeset
|
3134 term_font(int n) |
36843e079f64
patch 9.1.0030: Cannot use terminal alternate font
Christian Brabandt <cb@256bit.org>
parents:
34132
diff
changeset
|
3135 { |
36843e079f64
patch 9.1.0030: Cannot use terminal alternate font
Christian Brabandt <cb@256bit.org>
parents:
34132
diff
changeset
|
3136 if (*T_CFO) |
36843e079f64
patch 9.1.0030: Cannot use terminal alternate font
Christian Brabandt <cb@256bit.org>
parents:
34132
diff
changeset
|
3137 { |
36843e079f64
patch 9.1.0030: Cannot use terminal alternate font
Christian Brabandt <cb@256bit.org>
parents:
34132
diff
changeset
|
3138 char buf[20]; |
36843e079f64
patch 9.1.0030: Cannot use terminal alternate font
Christian Brabandt <cb@256bit.org>
parents:
34132
diff
changeset
|
3139 sprintf(buf, (char *)T_CFO, 9 + n); |
36843e079f64
patch 9.1.0030: Cannot use terminal alternate font
Christian Brabandt <cb@256bit.org>
parents:
34132
diff
changeset
|
3140 OUT_STR(buf); |
36843e079f64
patch 9.1.0030: Cannot use terminal alternate font
Christian Brabandt <cb@256bit.org>
parents:
34132
diff
changeset
|
3141 } |
36843e079f64
patch 9.1.0030: Cannot use terminal alternate font
Christian Brabandt <cb@256bit.org>
parents:
34132
diff
changeset
|
3142 } |
36843e079f64
patch 9.1.0030: Cannot use terminal alternate font
Christian Brabandt <cb@256bit.org>
parents:
34132
diff
changeset
|
3143 |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3144 static void |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3145 term_color(char_u *s, int n) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3146 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3147 char buf[20]; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3148 int i = *s == CSI ? 1 : 2; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3149 // index in s[] just after <Esc>[ or CSI |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3150 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3151 // Special handling of 16 colors, because termcap can't handle it |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3152 // Also accept "\e[3%dm" for TERMINFO, it is sometimes used |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3153 // Also accept CSI instead of <Esc>[ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3154 if (n >= 8 && t_colors >= 16 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3155 && ((s[0] == ESC && s[1] == '[') |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3156 #if defined(FEAT_VTP) && defined(FEAT_TERMGUICOLORS) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3157 || (s[0] == ESC && s[1] == '|') |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3158 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3159 || (s[0] == CSI && (i = 1) == 1)) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3160 && s[i] != NUL |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3161 && (STRCMP(s + i + 1, "%p1%dm") == 0 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3162 || STRCMP(s + i + 1, "%dm") == 0) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3163 && (s[i] == '3' || s[i] == '4')) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3164 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3165 #ifdef TERMINFO |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3166 char *format = "%s%s%%p1%%dm"; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3167 #else |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3168 char *format = "%s%s%%dm"; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3169 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3170 char *lead = i == 2 ? ( |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3171 #if defined(FEAT_VTP) && defined(FEAT_TERMGUICOLORS) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3172 s[1] == '|' ? "\033|" : |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3173 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3174 "\033[") : "\233"; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3175 char *tail = s[i] == '3' ? (n >= 16 ? "38;5;" : "9") |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3176 : (n >= 16 ? "48;5;" : "10"); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3177 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3178 sprintf(buf, format, lead, tail); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3179 OUT_STR(tgoto(buf, 0, n >= 16 ? n : n - 8)); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3180 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3181 else |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3182 OUT_STR(tgoto((char *)s, 0, n)); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3183 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3184 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3185 void |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3186 term_fg_color(int n) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3187 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3188 // Use "AF" termcap entry if present, "Sf" entry otherwise |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3189 if (*T_CAF) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3190 term_color(T_CAF, n); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3191 else if (*T_CSF) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3192 term_color(T_CSF, n); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3193 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3194 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3195 void |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3196 term_bg_color(int n) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3197 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3198 // Use "AB" termcap entry if present, "Sb" entry otherwise |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3199 if (*T_CAB) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3200 term_color(T_CAB, n); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3201 else if (*T_CSB) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3202 term_color(T_CSB, n); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3203 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3204 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3205 void |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3206 term_ul_color(int n) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3207 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3208 if (*T_CAU) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3209 term_color(T_CAU, n); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3210 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3211 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3212 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3213 * Return "dark" or "light" depending on the kind of terminal. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3214 * This is just guessing! Recognized are: |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3215 * "linux" Linux console |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3216 * "screen.linux" Linux console with screen |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3217 * "cygwin.*" Cygwin shell |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3218 * "putty.*" Putty program |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3219 * We also check the COLORFGBG environment variable, which is set by |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3220 * rxvt and derivatives. This variable contains either two or three |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3221 * values separated by semicolons; we want the last value in either |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3222 * case. If this value is 0-6 or 8, our background is dark. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3223 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3224 char_u * |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3225 term_bg_default(void) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3226 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3227 #if defined(MSWIN) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3228 // DOS console is nearly always black |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3229 return (char_u *)"dark"; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3230 #else |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3231 char_u *p; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3232 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3233 if (STRCMP(T_NAME, "linux") == 0 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3234 || STRCMP(T_NAME, "screen.linux") == 0 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3235 || STRNCMP(T_NAME, "cygwin", 6) == 0 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3236 || STRNCMP(T_NAME, "putty", 5) == 0 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3237 || ((p = mch_getenv((char_u *)"COLORFGBG")) != NULL |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3238 && (p = vim_strrchr(p, ';')) != NULL |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3239 && ((p[1] >= '0' && p[1] <= '6') || p[1] == '8') |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3240 && p[2] == NUL)) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3241 return (char_u *)"dark"; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3242 return (char_u *)"light"; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3243 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3244 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3245 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3246 #if defined(FEAT_TERMGUICOLORS) || defined(PROTO) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3247 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3248 #define RED(rgb) (((long_u)(rgb) >> 16) & 0xFF) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3249 #define GREEN(rgb) (((long_u)(rgb) >> 8) & 0xFF) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3250 #define BLUE(rgb) (((long_u)(rgb) ) & 0xFF) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3251 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3252 static void |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3253 term_rgb_color(char_u *s, guicolor_T rgb) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3254 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3255 #define MAX_COLOR_STR_LEN 100 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3256 char buf[MAX_COLOR_STR_LEN]; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3257 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3258 if (*s == NUL) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3259 return; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3260 vim_snprintf(buf, MAX_COLOR_STR_LEN, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3261 (char *)s, RED(rgb), GREEN(rgb), BLUE(rgb)); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3262 #ifdef FEAT_VTP |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3263 if (use_vtp() && (p_tgc || t_colors >= 256)) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3264 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3265 out_flush(); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3266 buf[1] = '['; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3267 vtp_printf(buf); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3268 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3269 else |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3270 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3271 OUT_STR(buf); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3272 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3273 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3274 void |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3275 term_fg_rgb_color(guicolor_T rgb) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3276 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3277 if (rgb != INVALCOLOR) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3278 term_rgb_color(T_8F, rgb); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3279 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3280 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3281 void |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3282 term_bg_rgb_color(guicolor_T rgb) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3283 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3284 if (rgb != INVALCOLOR) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3285 term_rgb_color(T_8B, rgb); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3286 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3287 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3288 void |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3289 term_ul_rgb_color(guicolor_T rgb) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3290 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3291 # ifdef FEAT_TERMRESPONSE |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3292 // If the user explicitly sets t_8u then use it. Otherwise wait for |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3293 // termresponse to be received, which is when t_8u would be set and a |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3294 // redraw is needed if it was used. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3295 if (!option_was_set((char_u *)"t_8u") && write_t_8u_state != OK) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3296 write_t_8u_state = MAYBE; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3297 else |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3298 # endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3299 term_rgb_color(T_8U, rgb); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3300 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3301 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3302 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3303 #if (defined(UNIX) || defined(VMS) || defined(MACOS_X)) || defined(PROTO) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3304 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3305 * Generic function to set window title, using t_ts and t_fs. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3306 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3307 void |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3308 term_settitle(char_u *title) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3309 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3310 MAY_WANT_TO_LOG_THIS; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3311 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3312 // t_ts takes one argument: column in status line |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3313 OUT_STR(tgoto((char *)T_TS, 0, 0)); // set title start |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3314 out_str_nf(title); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3315 out_str(T_FS); // set title end |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3316 out_flush(); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3317 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3318 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3319 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3320 * Tell the terminal to push (save) the title and/or icon, so that it can be |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3321 * popped (restored) later. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3322 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3323 void |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3324 term_push_title(int which) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3325 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3326 if ((which & SAVE_RESTORE_TITLE) && T_CST != NULL && *T_CST != NUL) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3327 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3328 OUT_STR(T_CST); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3329 out_flush(); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3330 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3331 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3332 if ((which & SAVE_RESTORE_ICON) && T_SSI != NULL && *T_SSI != NUL) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3333 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3334 OUT_STR(T_SSI); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3335 out_flush(); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3336 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3337 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3338 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3339 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3340 * Tell the terminal to pop the title and/or icon. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3341 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3342 void |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3343 term_pop_title(int which) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3344 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3345 if ((which & SAVE_RESTORE_TITLE) && T_CRT != NULL && *T_CRT != NUL) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3346 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3347 OUT_STR(T_CRT); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3348 out_flush(); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3349 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3350 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3351 if ((which & SAVE_RESTORE_ICON) && T_SRI != NULL && *T_SRI != NUL) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3352 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3353 OUT_STR(T_SRI); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3354 out_flush(); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3355 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3356 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3357 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3358 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3359 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3360 * Make sure we have a valid set or terminal options. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3361 * Replace all entries that are NULL by empty_option |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3362 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3363 void |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3364 ttest(int pairs) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3365 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3366 char_u *env_colors; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3367 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3368 check_options(); // make sure no options are NULL |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3369 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3370 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3371 * MUST have "cm": cursor motion. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3372 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3373 if (*T_CM == NUL) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3374 emsg(_(e_terminal_capability_cm_required)); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3375 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3376 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3377 * if "cs" defined, use a scroll region, it's faster. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3378 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3379 if (*T_CS != NUL) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3380 scroll_region = TRUE; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3381 else |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3382 scroll_region = FALSE; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3383 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3384 if (pairs) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3385 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3386 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3387 * optional pairs |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3388 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3389 // TP goes to normal mode for TI (invert) and TB (bold) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3390 if (*T_ME == NUL) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3391 T_ME = T_MR = T_MD = T_MB = empty_option; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3392 if (*T_SO == NUL || *T_SE == NUL) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3393 T_SO = T_SE = empty_option; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3394 if (*T_US == NUL || *T_UE == NUL) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3395 T_US = T_UE = empty_option; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3396 if (*T_CZH == NUL || *T_CZR == NUL) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3397 T_CZH = T_CZR = empty_option; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3398 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3399 // T_VE is needed even though T_VI is not defined |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3400 if (*T_VE == NUL) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3401 T_VI = empty_option; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3402 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3403 // if 'mr' or 'me' is not defined use 'so' and 'se' |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3404 if (*T_ME == NUL) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3405 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3406 T_ME = T_SE; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3407 T_MR = T_SO; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3408 T_MD = T_SO; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3409 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3410 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3411 // if 'so' or 'se' is not defined use 'mr' and 'me' |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3412 if (*T_SO == NUL) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3413 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3414 T_SE = T_ME; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3415 if (*T_MR == NUL) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3416 T_SO = T_MD; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3417 else |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3418 T_SO = T_MR; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3419 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3420 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3421 // if 'ZH' or 'ZR' is not defined use 'mr' and 'me' |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3422 if (*T_CZH == NUL) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3423 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3424 T_CZR = T_ME; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3425 if (*T_MR == NUL) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3426 T_CZH = T_MD; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3427 else |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3428 T_CZH = T_MR; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3429 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3430 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3431 // "Sb" and "Sf" come in pairs |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3432 if (*T_CSB == NUL || *T_CSF == NUL) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3433 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3434 T_CSB = empty_option; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3435 T_CSF = empty_option; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3436 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3437 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3438 // "AB" and "AF" come in pairs |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3439 if (*T_CAB == NUL || *T_CAF == NUL) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3440 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3441 T_CAB = empty_option; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3442 T_CAF = empty_option; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3443 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3444 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3445 // if 'Sb' and 'AB' are not defined, reset "Co" |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3446 if (*T_CSB == NUL && *T_CAB == NUL) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3447 free_one_termoption(T_CCO); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3448 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3449 // Set 'weirdinvert' according to value of 't_xs' |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3450 p_wiv = (*T_XS != NUL); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3451 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3452 need_gather = TRUE; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3453 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3454 // Set t_colors to the value of $COLORS or t_Co. Ignore $COLORS in the |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3455 // GUI. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3456 t_colors = atoi((char *)T_CCO); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3457 #ifdef FEAT_GUI |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3458 if (!gui.in_use) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3459 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3460 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3461 env_colors = mch_getenv((char_u *)"COLORS"); |
34074
1629cc65d78d
patch 9.1.0006: is*() and to*() function may be unsafe
Christian Brabandt <cb@256bit.org>
parents:
33888
diff
changeset
|
3462 if (env_colors != NULL && SAFE_isdigit(*env_colors)) |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3463 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3464 int colors = atoi((char *)env_colors); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3465 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3466 if (colors != t_colors) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3467 set_color_count(colors); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3468 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3469 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3470 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3471 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3472 #if (defined(FEAT_GUI) && (defined(FEAT_MENU) || !defined(USE_ON_FLY_SCROLL))) \ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3473 || defined(PROTO) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3474 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3475 * Represent the given long_u as individual bytes, with the most significant |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3476 * byte first, and store them in dst. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3477 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3478 void |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3479 add_long_to_buf(long_u val, char_u *dst) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3480 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3481 int i; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3482 int shift; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3483 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3484 for (i = 1; i <= (int)sizeof(long_u); i++) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3485 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3486 shift = 8 * (sizeof(long_u) - i); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3487 dst[i - 1] = (char_u) ((val >> shift) & 0xff); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3488 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3489 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3490 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3491 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3492 * Interpret the next string of bytes in buf as a long integer, with the most |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3493 * significant byte first. Note that it is assumed that buf has been through |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3494 * inchar(), so that NUL and K_SPECIAL will be represented as three bytes each. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3495 * Puts result in val, and returns the number of bytes read from buf |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3496 * (between sizeof(long_u) and 2 * sizeof(long_u)), or -1 if not enough bytes |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3497 * were present. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3498 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3499 static int |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3500 get_long_from_buf(char_u *buf, long_u *val) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3501 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3502 int len; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3503 char_u bytes[sizeof(long_u)]; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3504 int i; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3505 int shift; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3506 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3507 *val = 0; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3508 len = get_bytes_from_buf(buf, bytes, (int)sizeof(long_u)); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3509 if (len == -1) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3510 return -1; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3511 for (i = 0; i < (int)sizeof(long_u); i++) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3512 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3513 shift = 8 * (sizeof(long_u) - 1 - i); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3514 *val += (long_u)bytes[i] << shift; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3515 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3516 return len; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3517 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3518 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3519 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3520 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3521 * Read the next num_bytes bytes from buf, and store them in bytes. Assume |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3522 * that buf has been through inchar(). Returns the actual number of bytes used |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3523 * from buf (between num_bytes and num_bytes*2), or -1 if not enough bytes were |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3524 * available. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3525 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3526 int |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3527 get_bytes_from_buf(char_u *buf, char_u *bytes, int num_bytes) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3528 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3529 int len = 0; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3530 int i; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3531 char_u c; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3532 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3533 for (i = 0; i < num_bytes; i++) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3534 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3535 if ((c = buf[len++]) == NUL) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3536 return -1; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3537 if (c == K_SPECIAL) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3538 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3539 if (buf[len] == NUL || buf[len + 1] == NUL) // cannot happen? |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3540 return -1; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3541 if (buf[len++] == (int)KS_ZERO) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3542 c = NUL; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3543 // else it should be KS_SPECIAL; when followed by KE_FILLER c is |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3544 // K_SPECIAL, or followed by KE_CSI and c must be CSI. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3545 if (buf[len++] == (int)KE_CSI) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3546 c = CSI; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3547 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3548 else if (c == CSI && buf[len] == KS_EXTRA |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3549 && buf[len + 1] == (int)KE_CSI) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3550 // CSI is stored as CSI KS_SPECIAL KE_CSI to avoid confusion with |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3551 // the start of a special key, see add_to_input_buf_csi(). |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3552 len += 2; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3553 bytes[i] = c; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3554 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3555 return len; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3556 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3557 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3558 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3559 * Check if the new shell size is valid, correct it if it's too small or way |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3560 * too big. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3561 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3562 void |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3563 check_shellsize(void) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3564 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3565 if (Rows < min_rows()) // need room for one window and command line |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3566 Rows = min_rows(); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3567 limit_screen_size(); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3568 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3569 // make sure these values are not invalid |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3570 if (cmdline_row >= Rows) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3571 cmdline_row = Rows - 1; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3572 if (msg_row >= Rows) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3573 msg_row = Rows - 1; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3574 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3575 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3576 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3577 * Limit Rows and Columns to avoid an overflow in Rows * Columns. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3578 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3579 void |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3580 limit_screen_size(void) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3581 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3582 if (Columns < MIN_COLUMNS) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3583 Columns = MIN_COLUMNS; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3584 else if (Columns > 10000) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3585 Columns = 10000; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3586 if (Rows > 1000) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3587 Rows = 1000; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3588 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3589 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3590 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3591 * Invoked just before the screen structures are going to be (re)allocated. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3592 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3593 void |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3594 win_new_shellsize(void) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3595 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3596 static int old_Rows = 0; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3597 static int old_Columns = 0; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3598 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3599 if (old_Rows != Rows || old_Columns != Columns) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3600 ui_new_shellsize(); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3601 if (old_Rows != Rows) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3602 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3603 // If 'window' uses the whole screen, keep it using that. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3604 // Don't change it when set with "-w size" on the command line. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3605 if (p_window == old_Rows - 1 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3606 || (old_Rows == 0 && !option_was_set((char_u *)"window"))) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3607 p_window = Rows - 1; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3608 old_Rows = Rows; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3609 shell_new_rows(); // update window sizes |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3610 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3611 if (old_Columns != Columns) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3612 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3613 old_Columns = Columns; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3614 shell_new_columns(); // update window sizes |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3615 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3616 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3617 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3618 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3619 * Call this function when the Vim shell has been resized in any way. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3620 * Will obtain the current size and redraw (also when size didn't change). |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3621 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3622 void |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3623 shell_resized(void) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3624 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3625 set_shellsize(0, 0, FALSE); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3626 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3627 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3628 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3629 * Check if the shell size changed. Handle a resize. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3630 * When the size didn't change, nothing happens. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3631 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3632 void |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3633 shell_resized_check(void) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3634 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3635 int old_Rows = Rows; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3636 int old_Columns = Columns; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3637 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3638 if (exiting |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3639 #ifdef FEAT_GUI |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3640 // Do not get the size when executing a shell command during |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3641 // startup. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3642 || gui.starting |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3643 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3644 ) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3645 return; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3646 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3647 (void)ui_get_shellsize(); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3648 check_shellsize(); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3649 if (old_Rows != Rows || old_Columns != Columns) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3650 shell_resized(); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3651 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3652 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3653 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3654 * Set size of the Vim shell. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3655 * If 'mustset' is TRUE, we must set Rows and Columns, do not get the real |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3656 * window size (this is used for the :win command). |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3657 * If 'mustset' is FALSE, we may try to get the real window size and if |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3658 * it fails use 'width' and 'height'. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3659 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3660 static void |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3661 set_shellsize_inner(int width, int height, int mustset) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3662 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3663 if (updating_screen) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3664 // resizing while in update_screen() may cause a crash |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3665 return; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3666 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3667 // curwin->w_buffer can be NULL when we are closing a window and the |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3668 // buffer (or window) has already been closed and removing a scrollbar |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3669 // causes a resize event. Don't resize then, it will happen after entering |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3670 // another buffer. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3671 if (curwin->w_buffer == NULL || curwin->w_lines == NULL) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3672 return; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3673 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3674 #ifdef AMIGA |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3675 out_flush(); // must do this before mch_get_shellsize() for |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3676 // some obscure reason |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3677 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3678 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3679 if (mustset || (ui_get_shellsize() == FAIL && height != 0)) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3680 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3681 Rows = height; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3682 Columns = width; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3683 check_shellsize(); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3684 ui_set_shellsize(mustset); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3685 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3686 else |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3687 check_shellsize(); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3688 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3689 // The window layout used to be adjusted here, but it now happens in |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3690 // screenalloc() (also invoked from screenclear()). That is because the |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3691 // "busy" check above may skip this, but not screenalloc(). |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3692 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3693 if (State != MODE_ASKMORE && State != MODE_EXTERNCMD |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3694 && State != MODE_CONFIRM) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3695 screenclear(); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3696 else |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3697 screen_start(); // don't know where cursor is now |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3698 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3699 if (starting != NO_SCREEN) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3700 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3701 maketitle(); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3702 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3703 changed_line_abv_curs(); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3704 invalidate_botline(); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3705 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3706 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3707 * We only redraw when it's needed: |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3708 * - While at the more prompt or executing an external command, don't |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3709 * redraw, but position the cursor. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3710 * - While editing the command line, only redraw that. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3711 * - in Ex mode, don't redraw anything. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3712 * - Otherwise, redraw right now, and position the cursor. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3713 * Always need to call update_screen() or screenalloc(), to make |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3714 * sure Rows/Columns and the size of ScreenLines[] is correct! |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3715 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3716 if (State == MODE_ASKMORE || State == MODE_EXTERNCMD |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3717 || State == MODE_CONFIRM || exmode_active) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3718 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3719 screenalloc(FALSE); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3720 repeat_message(); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3721 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3722 else |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3723 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3724 if (curwin->w_p_scb) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3725 do_check_scrollbind(TRUE); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3726 if (State & MODE_CMDLINE) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3727 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3728 update_screen(UPD_NOT_VALID); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3729 redrawcmdline(); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3730 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3731 else |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3732 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3733 update_topline(); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3734 if (pum_visible()) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3735 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3736 redraw_later(UPD_NOT_VALID); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3737 ins_compl_show_pum(); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3738 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3739 update_screen(UPD_NOT_VALID); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3740 if (redrawing()) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3741 setcursor(); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3742 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3743 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3744 cursor_on(); // redrawing may have switched it off |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3745 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3746 out_flush(); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3747 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3748 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3749 void |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3750 set_shellsize(int width, int height, int mustset) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3751 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3752 static int busy = FALSE; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3753 static int do_run = FALSE; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3754 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3755 if (width < 0 || height < 0) // just checking... |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3756 return; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3757 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3758 if (State == MODE_HITRETURN || State == MODE_SETWSIZE) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3759 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3760 // postpone the resizing |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3761 State = MODE_SETWSIZE; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3762 return; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3763 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3764 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3765 // Avoid recursiveness. This can happen when setting the window size |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3766 // causes another window-changed signal or when two SIGWINCH signals come |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3767 // very close together. There needs to be another run then after the |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3768 // current one is done to pick up the latest size. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3769 do_run = TRUE; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3770 if (busy) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3771 return; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3772 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3773 while (do_run) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3774 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3775 do_run = FALSE; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3776 busy = TRUE; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3777 set_shellsize_inner(width, height, mustset); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3778 busy = FALSE; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3779 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3780 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3781 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3782 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3783 * Output T_CTE, the t_TE termcap entry, and handle expected effects. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3784 * The code possibly disables modifyOtherKeys and the Kitty keyboard protocol. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3785 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3786 void |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3787 out_str_t_TE(void) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3788 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3789 out_str(T_CTE); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3790 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3791 // The seenModifyOtherKeys flag is not reset here. We do expect t_TE to |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3792 // disable modifyOtherKeys, but until Xterm version 377 there is no way to |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3793 // detect it's enabled again after the following t_TI. We assume that when |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3794 // seenModifyOtherKeys was set before it will still be valid. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3795 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3796 // When the modifyOtherKeys level is detected to be 2 we expect t_TE to |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3797 // disable it. Remembering that it was detected to be enabled is useful in |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3798 // some situations. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3799 // The following t_TI is expected to request the state and then |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3800 // modify_otherkeys_state will be set again. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3801 if (modify_otherkeys_state == MOKS_ENABLED |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3802 || modify_otherkeys_state == MOKS_DISABLED) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3803 modify_otherkeys_state = MOKS_DISABLED; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3804 else if (modify_otherkeys_state != MOKS_INITIAL) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3805 modify_otherkeys_state = MOKS_AFTER_T_TE; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3806 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3807 // When the kitty keyboard protocol is enabled we expect t_TE to disable |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3808 // it. Remembering that it was detected to be enabled is useful in some |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3809 // situations. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3810 // The following t_TI is expected to request the state and then |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3811 // kitty_protocol_state will be set again. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3812 if (kitty_protocol_state == KKPS_ENABLED |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3813 || kitty_protocol_state == KKPS_DISABLED) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3814 kitty_protocol_state = KKPS_DISABLED; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3815 else |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3816 kitty_protocol_state = KKPS_AFTER_T_TE; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3817 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3818 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3819 static int send_t_RK = FALSE; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3820 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3821 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3822 * Output T_TI and setup for what follows. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3823 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3824 void |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3825 out_str_t_TI(void) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3826 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3827 out_str(T_CTI); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3828 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3829 // Send t_RK when there is no more work to do. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3830 send_t_RK = TRUE; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3831 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3832 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3833 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3834 * Output T_BE, but only when t_PS and t_PE are set. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3835 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3836 void |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3837 out_str_t_BE(void) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3838 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3839 char_u *p; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3840 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3841 if (T_BE == NULL || *T_BE == NUL |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3842 || (p = find_termcode((char_u *)"PS")) == NULL || *p == NUL |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3843 || (p = find_termcode((char_u *)"PE")) == NULL || *p == NUL) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3844 return; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3845 out_str(T_BE); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3846 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3847 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3848 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3849 * If t_TI was recently sent and there is no typeahead or work to do, now send |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3850 * t_RK. This is postponed to avoid the response arriving in a shell command |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3851 * or after Vim exits. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3852 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3853 void |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3854 may_send_t_RK(void) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3855 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3856 if (send_t_RK |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3857 && !work_pending() |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3858 && !ex_normal_busy |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3859 #ifdef FEAT_EVAL |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3860 && !in_feedkeys |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3861 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3862 && !exiting) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3863 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3864 send_t_RK = FALSE; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3865 out_str(T_CRK); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3866 out_flush(); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3867 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3868 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3869 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3870 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3871 * Set the terminal to TMODE_RAW (for Normal mode) or TMODE_COOK (for external |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3872 * commands and Ex mode). |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3873 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3874 void |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3875 settmode(tmode_T tmode) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3876 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3877 #ifdef FEAT_GUI |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3878 // don't set the term where gvim was started to any mode |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3879 if (gui.in_use) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3880 return; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3881 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3882 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3883 if (!full_screen) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3884 return; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3885 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3886 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3887 * When returning after calling a shell cur_tmode is TMODE_UNKNOWN, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3888 * set the terminal to raw mode, even though we think it already is, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3889 * because the shell program may have reset the terminal mode. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3890 * When we think the terminal is normal, don't try to set it to |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3891 * normal again, because that causes problems (logout!) on some |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3892 * machines. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3893 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3894 if (tmode != cur_tmode) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3895 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3896 #ifdef FEAT_TERMRESPONSE |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3897 # ifdef FEAT_GUI |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3898 if (!gui.in_use && !gui.starting) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3899 # endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3900 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3901 // May need to check for T_CRV response and termcodes, it |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3902 // doesn't work in Cooked mode, an external program may get |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3903 // them. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3904 if (tmode != TMODE_RAW && termrequest_any_pending()) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3905 (void)vpeekc_nomap(); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3906 check_for_codes_from_term(); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3907 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3908 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3909 if (tmode != TMODE_RAW) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3910 mch_setmouse(FALSE); // switch mouse off |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3911 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3912 // Disable bracketed paste and modifyOtherKeys in cooked mode. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3913 // Avoid doing this too often, on some terminals the codes are not |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3914 // handled properly. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3915 if (termcap_active && tmode != TMODE_SLEEP |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3916 && cur_tmode != TMODE_SLEEP) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3917 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3918 MAY_WANT_TO_LOG_THIS; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3919 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3920 if (tmode != TMODE_RAW) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3921 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3922 out_str(T_BD); // disable bracketed paste mode |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3923 out_str_t_TE(); // possibly disables modifyOtherKeys |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3924 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3925 else |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3926 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3927 out_str_t_BE(); // enable bracketed paste mode (should |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3928 // be before mch_settmode(). |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3929 out_str_t_TI(); // possibly enables modifyOtherKeys |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3930 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3931 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3932 out_flush(); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3933 mch_settmode(tmode); // machine specific function |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3934 cur_tmode = tmode; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3935 if (tmode == TMODE_RAW) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3936 setmouse(); // may switch mouse on |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3937 out_flush(); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3938 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3939 #ifdef FEAT_TERMRESPONSE |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3940 may_req_termresponse(); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3941 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3942 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3943 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3944 void |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3945 starttermcap(void) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3946 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3947 if (!full_screen || termcap_active) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3948 return; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3949 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3950 MAY_WANT_TO_LOG_THIS; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3951 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3952 out_str(T_TI); // start termcap mode |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3953 out_str_t_TI(); // start "raw" mode |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3954 out_str(T_KS); // start "keypad transmit" mode |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3955 out_str_t_BE(); // enable bracketed paste mode |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3956 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3957 #if defined(UNIX) || defined(VMS) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3958 // Enable xterm's focus reporting mode when 'esckeys' is set. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3959 if (p_ek && *T_FE != NUL) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3960 out_str(T_FE); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3961 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3962 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3963 out_flush(); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3964 termcap_active = TRUE; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3965 screen_start(); // don't know where cursor is now |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3966 #ifdef FEAT_TERMRESPONSE |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3967 # ifdef FEAT_GUI |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3968 if (!gui.in_use && !gui.starting) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3969 # endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3970 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3971 may_req_termresponse(); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3972 // Immediately check for a response. If t_Co changes, we don't |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3973 // want to redraw with wrong colors first. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3974 if (crv_status.tr_progress == STATUS_SENT) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3975 check_for_codes_from_term(); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3976 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3977 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3978 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3979 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3980 void |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3981 stoptermcap(void) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3982 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3983 screen_stop_highlight(); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3984 reset_cterm_colors(); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3985 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3986 if (!termcap_active) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3987 return; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3988 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3989 #ifdef FEAT_TERMRESPONSE |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3990 # ifdef FEAT_GUI |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3991 if (!gui.in_use && !gui.starting) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3992 # endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3993 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3994 // May need to discard T_CRV, T_U7 or T_RBG response. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3995 if (termrequest_any_pending()) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3996 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3997 # ifdef UNIX |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3998 // Give the terminal a chance to respond. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
3999 mch_delay(100L, 0); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4000 # endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4001 # ifdef TCIFLUSH |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4002 // Discard data received but not read. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4003 if (exiting) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4004 tcflush(fileno(stdin), TCIFLUSH); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4005 # endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4006 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4007 // Check for termcodes first, otherwise an external program may |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4008 // get them. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4009 check_for_codes_from_term(); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4010 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4011 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4012 MAY_WANT_TO_LOG_THIS; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4013 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4014 #if defined(UNIX) || defined(VMS) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4015 // Disable xterm's focus reporting mode if 'esckeys' is set. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4016 if (p_ek && *T_FD != NUL) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4017 out_str(T_FD); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4018 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4019 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4020 out_str(T_BD); // disable bracketed paste mode |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4021 out_str(T_KE); // stop "keypad transmit" mode |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4022 out_flush(); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4023 termcap_active = FALSE; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4024 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4025 // Output t_te before t_TE, t_te may switch between main and alternate |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4026 // screen and following codes may work on the active screen only. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4027 // |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4028 // When using the Kitty keyboard protocol the main and alternate screen |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4029 // use a separate state. If we are (or were) using the Kitty keyboard |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4030 // protocol and t_te is not empty (possibly switching screens) then |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4031 // output t_TE both before and after outputting t_te. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4032 if (*T_TE != NUL && (kitty_protocol_state == KKPS_ENABLED |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4033 || kitty_protocol_state == KKPS_DISABLED)) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4034 out_str_t_TE(); // probably disables the kitty keyboard |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4035 // protocol |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4036 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4037 out_str(T_TE); // stop termcap mode |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4038 cursor_on(); // just in case it is still off |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4039 out_str_t_TE(); // stop "raw" mode, modifyOtherKeys and |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4040 // Kitty keyboard protocol |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4041 screen_start(); // don't know where cursor is now |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4042 out_flush(); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4043 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4044 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4045 #if defined(FEAT_TERMRESPONSE) || defined(PROTO) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4046 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4047 * Request version string (for xterm) when needed. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4048 * Only do this after switching to raw mode, otherwise the result will be |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4049 * echoed. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4050 * Only do this after startup has finished, to avoid that the response comes |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4051 * while executing "-c !cmd" or even after "-c quit". |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4052 * Only do this after termcap mode has been started, otherwise the codes for |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4053 * the cursor keys may be wrong. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4054 * Only do this when 'esckeys' is on, otherwise the response causes trouble in |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4055 * Insert mode. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4056 * On Unix only do it when both output and input are a tty (avoid writing |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4057 * request to terminal while reading from a file). |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4058 * The result is caught in check_termcode(). |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4059 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4060 void |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4061 may_req_termresponse(void) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4062 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4063 if (crv_status.tr_progress == STATUS_GET |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4064 && can_get_termresponse() |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4065 && starting == 0 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4066 && *T_CRV != NUL) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4067 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4068 MAY_WANT_TO_LOG_THIS; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4069 LOG_TR(("Sending CRV request")); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4070 out_str(T_CRV); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4071 termrequest_sent(&crv_status); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4072 // check for the characters now, otherwise they might be eaten by |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4073 // get_keystroke() |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4074 out_flush(); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4075 (void)vpeekc_nomap(); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4076 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4077 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4078 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4079 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4080 * Send sequences to the terminal and check with t_u7 how the cursor moves, to |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4081 * find out properties of the terminal. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4082 * Note that this goes out before T_CRV, so that the result can be used when |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4083 * the termresponse arrives. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4084 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4085 void |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4086 check_terminal_behavior(void) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4087 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4088 int did_send = FALSE; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4089 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4090 if (!can_get_termresponse() || starting != 0 || *T_U7 == NUL) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4091 return; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4092 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4093 if (u7_status.tr_progress == STATUS_GET |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4094 && !option_was_set((char_u *)"ambiwidth")) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4095 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4096 char_u buf[16]; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4097 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4098 // Ambiguous width check. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4099 // Check how the terminal treats ambiguous character width (UAX #11). |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4100 // First, we move the cursor to (1, 0) and print a test ambiguous |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4101 // character \u25bd (WHITE DOWN-POINTING TRIANGLE) and then query |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4102 // the current cursor position. If the terminal treats \u25bd as |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4103 // single width, the position is (1, 1), or if it is treated as double |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4104 // width, that will be (1, 2). This function has the side effect that |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4105 // changes cursor position, so it must be called immediately after |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4106 // entering termcap mode. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4107 MAY_WANT_TO_LOG_THIS; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4108 LOG_TR(("Sending request for ambiwidth check")); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4109 // Do this in the second row. In the first row the returned sequence |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4110 // may be CSI 1;2R, which is the same as <S-F3>. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4111 term_windgoto(1, 0); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4112 buf[mb_char2bytes(0x25bd, buf)] = NUL; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4113 out_str(buf); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4114 out_str(T_U7); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4115 termrequest_sent(&u7_status); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4116 out_flush(); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4117 did_send = TRUE; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4118 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4119 // This overwrites a few characters on the screen, a redraw is needed |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4120 // after this. Clear them out for now. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4121 screen_stop_highlight(); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4122 term_windgoto(1, 0); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4123 out_str((char_u *)" "); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4124 line_was_clobbered(1); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4125 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4126 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4127 if (xcc_status.tr_progress == STATUS_GET && Rows > 2) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4128 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4129 // 2. Check compatibility with xterm. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4130 // We move the cursor to (2, 0), print a test sequence and then query |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4131 // the current cursor position. If the terminal properly handles |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4132 // unknown DCS string and CSI sequence with intermediate byte, the test |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4133 // sequence is ignored and the cursor does not move. If the terminal |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4134 // handles test sequence incorrectly, a garbage string is displayed and |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4135 // the cursor does move. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4136 MAY_WANT_TO_LOG_THIS; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4137 LOG_TR(("Sending xterm compatibility test sequence.")); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4138 // Do this in the third row. Second row is used by ambiguous |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4139 // character width check. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4140 term_windgoto(2, 0); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4141 // send the test DCS string. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4142 out_str((char_u *)"\033Pzz\033\\"); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4143 // send the test CSI sequence with intermediate byte. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4144 out_str((char_u *)"\033[0%m"); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4145 out_str(T_U7); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4146 termrequest_sent(&xcc_status); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4147 out_flush(); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4148 did_send = TRUE; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4149 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4150 // If the terminal handles test sequence incorrectly, garbage text is |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4151 // displayed. Clear them out for now. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4152 screen_stop_highlight(); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4153 term_windgoto(2, 0); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4154 out_str((char_u *)" "); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4155 line_was_clobbered(2); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4156 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4157 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4158 if (did_send) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4159 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4160 term_windgoto(0, 0); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4161 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4162 // Need to reset the known cursor position. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4163 screen_start(); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4164 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4165 // check for the characters now, otherwise they might be eaten by |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4166 // get_keystroke() |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4167 out_flush(); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4168 (void)vpeekc_nomap(); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4169 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4170 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4171 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4172 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4173 * Similar to requesting the version string: Request the terminal background |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4174 * color when it is the right moment. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4175 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4176 void |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4177 may_req_bg_color(void) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4178 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4179 if (can_get_termresponse() && starting == 0) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4180 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4181 int didit = FALSE; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4182 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4183 # ifdef FEAT_TERMINAL |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4184 // Only request foreground if t_RF is set. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4185 if (rfg_status.tr_progress == STATUS_GET && *T_RFG != NUL) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4186 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4187 MAY_WANT_TO_LOG_THIS; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4188 LOG_TR(("Sending FG request")); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4189 out_str(T_RFG); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4190 termrequest_sent(&rfg_status); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4191 didit = TRUE; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4192 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4193 # endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4194 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4195 // Only request background if t_RB is set. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4196 if (rbg_status.tr_progress == STATUS_GET && *T_RBG != NUL) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4197 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4198 MAY_WANT_TO_LOG_THIS; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4199 LOG_TR(("Sending BG request")); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4200 out_str(T_RBG); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4201 termrequest_sent(&rbg_status); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4202 didit = TRUE; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4203 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4204 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4205 if (didit) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4206 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4207 // check for the characters now, otherwise they might be eaten by |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4208 // get_keystroke() |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4209 out_flush(); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4210 (void)vpeekc_nomap(); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4211 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4212 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4213 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4214 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4215 # ifdef DEBUG_TERMRESPONSE |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4216 static void |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4217 log_tr(const char *fmt, ...) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4218 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4219 static FILE *fd_tr = NULL; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4220 static proftime_T start; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4221 proftime_T now; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4222 va_list ap; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4223 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4224 if (fd_tr == NULL) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4225 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4226 fd_tr = fopen("termresponse.log", "w"); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4227 profile_start(&start); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4228 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4229 now = start; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4230 profile_end(&now); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4231 fprintf(fd_tr, "%s: %s ", profile_msg(&now), |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4232 must_redraw == UPD_NOT_VALID ? "NV" |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4233 : must_redraw == UPD_CLEAR ? "CL" : " "); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4234 va_start(ap, fmt); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4235 vfprintf(fd_tr, fmt, ap); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4236 va_end(ap); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4237 fputc('\n', fd_tr); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4238 fflush(fd_tr); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4239 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4240 # endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4241 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4242 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4243 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4244 * Return TRUE when saving and restoring the screen. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4245 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4246 int |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4247 swapping_screen(void) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4248 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4249 return (full_screen && *T_TI != NUL); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4250 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4251 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4252 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4253 * By outputting the 'cursor very visible' termcap code, for some windowed |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4254 * terminals this makes the screen scrolled to the correct position. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4255 * Used when starting Vim or returning from a shell. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4256 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4257 void |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4258 scroll_start(void) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4259 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4260 if (*T_VS == NUL || *T_CVS == NUL) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4261 return; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4262 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4263 MAY_WANT_TO_LOG_THIS; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4264 out_str(T_VS); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4265 out_str(T_CVS); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4266 screen_start(); // don't know where cursor is now |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4267 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4268 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4269 // True if cursor is not visible |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4270 static int cursor_is_off = FALSE; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4271 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4272 // True if cursor is not visible due to an ongoing cursor-less sleep |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4273 static int cursor_is_asleep = FALSE; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4274 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4275 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4276 * Enable the cursor without checking if it's already enabled. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4277 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4278 void |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4279 cursor_on_force(void) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4280 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4281 out_str(T_VE); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4282 cursor_is_off = FALSE; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4283 cursor_is_asleep = FALSE; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4284 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4285 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4286 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4287 * Enable the cursor if it's currently off. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4288 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4289 void |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4290 cursor_on(void) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4291 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4292 if (cursor_is_off && !cursor_is_asleep) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4293 cursor_on_force(); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4294 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4295 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4296 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4297 * Disable the cursor. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4298 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4299 void |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4300 cursor_off(void) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4301 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4302 if (full_screen && !cursor_is_off) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4303 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4304 out_str(T_VI); // disable cursor |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4305 cursor_is_off = TRUE; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4306 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4307 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4308 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4309 #ifdef FEAT_GUI |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4310 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4311 * Check whether the cursor is invisible due to an ongoing cursor-less sleep |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4312 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4313 int |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4314 cursor_is_sleeping(void) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4315 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4316 return cursor_is_asleep; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4317 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4318 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4319 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4320 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4321 * Disable the cursor and mark it disabled by cursor-less sleep |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4322 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4323 void |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4324 cursor_sleep(void) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4325 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4326 cursor_is_asleep = TRUE; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4327 cursor_off(); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4328 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4329 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4330 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4331 * Enable the cursor and mark it not disabled by cursor-less sleep |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4332 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4333 void |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4334 cursor_unsleep(void) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4335 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4336 cursor_is_asleep = FALSE; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4337 cursor_on(); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4338 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4339 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4340 #if defined(CURSOR_SHAPE) || defined(PROTO) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4341 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4342 * Set cursor shape to match Insert or Replace mode. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4343 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4344 void |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4345 term_cursor_mode(int forced) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4346 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4347 static int showing_mode = -1; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4348 char_u *p; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4349 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4350 // Only do something when redrawing the screen and we can restore the |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4351 // mode. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4352 if (!full_screen || *T_CEI == NUL) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4353 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4354 # ifdef FEAT_TERMRESPONSE |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4355 if (forced && initial_cursor_shape > 0) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4356 // Restore to initial values. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4357 term_cursor_shape(initial_cursor_shape, initial_cursor_blink); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4358 # endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4359 return; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4360 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4361 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4362 if ((State & MODE_REPLACE) == MODE_REPLACE) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4363 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4364 if (forced || showing_mode != MODE_REPLACE) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4365 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4366 if (*T_CSR != NUL) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4367 p = T_CSR; // Replace mode cursor |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4368 else |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4369 p = T_CSI; // fall back to Insert mode cursor |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4370 if (*p != NUL) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4371 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4372 out_str(p); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4373 showing_mode = MODE_REPLACE; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4374 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4375 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4376 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4377 else if (State & MODE_INSERT) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4378 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4379 if ((forced || showing_mode != MODE_INSERT) && *T_CSI != NUL) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4380 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4381 out_str(T_CSI); // Insert mode cursor |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4382 showing_mode = MODE_INSERT; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4383 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4384 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4385 else if (forced || showing_mode != MODE_NORMAL) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4386 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4387 out_str(T_CEI); // non-Insert mode cursor |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4388 showing_mode = MODE_NORMAL; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4389 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4390 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4391 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4392 # if defined(FEAT_TERMINAL) || defined(PROTO) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4393 void |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4394 term_cursor_color(char_u *color) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4395 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4396 if (*T_CSC == NUL) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4397 return; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4398 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4399 out_str(T_CSC); // set cursor color start |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4400 out_str_nf(color); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4401 out_str(T_CEC); // set cursor color end |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4402 out_flush(); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4403 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4404 # endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4405 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4406 int |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4407 blink_state_is_inverted(void) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4408 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4409 #ifdef FEAT_TERMRESPONSE |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4410 return rbm_status.tr_progress == STATUS_GOT |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4411 && rcs_status.tr_progress == STATUS_GOT |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4412 && initial_cursor_blink != initial_cursor_shape_blink; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4413 #else |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4414 return FALSE; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4415 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4416 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4417 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4418 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4419 * "shape": 1 = block, 2 = underline, 3 = vertical bar |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4420 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4421 void |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4422 term_cursor_shape(int shape, int blink) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4423 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4424 if (*T_CSH != NUL) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4425 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4426 OUT_STR(tgoto((char *)T_CSH, 0, shape * 2 - blink)); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4427 out_flush(); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4428 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4429 else |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4430 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4431 int do_blink = blink; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4432 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4433 // t_SH is empty: try setting just the blink state. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4434 // The blink flags are XORed together, if the initial blinking from |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4435 // style and shape differs, we need to invert the flag here. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4436 if (blink_state_is_inverted()) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4437 do_blink = !blink; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4438 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4439 if (do_blink && *T_VS != NUL) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4440 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4441 out_str(T_VS); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4442 out_flush(); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4443 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4444 else if (!do_blink && *T_CVS != NUL) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4445 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4446 out_str(T_CVS); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4447 out_flush(); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4448 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4449 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4450 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4451 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4452 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4453 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4454 * Set scrolling region for window 'wp'. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4455 * The region starts 'off' lines from the start of the window. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4456 * Also set the vertical scroll region for a vertically split window. Always |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4457 * the full width of the window, excluding the vertical separator. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4458 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4459 void |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4460 scroll_region_set(win_T *wp, int off) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4461 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4462 OUT_STR(tgoto((char *)T_CS, W_WINROW(wp) + wp->w_height - 1, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4463 W_WINROW(wp) + off)); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4464 if (*T_CSV != NUL && wp->w_width != Columns) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4465 OUT_STR(tgoto((char *)T_CSV, wp->w_wincol + wp->w_width - 1, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4466 wp->w_wincol)); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4467 screen_start(); // don't know where cursor is now |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4468 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4469 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4470 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4471 * Reset scrolling region to the whole screen. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4472 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4473 void |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4474 scroll_region_reset(void) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4475 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4476 OUT_STR(tgoto((char *)T_CS, (int)Rows - 1, 0)); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4477 if (*T_CSV != NUL) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4478 OUT_STR(tgoto((char *)T_CSV, (int)Columns - 1, 0)); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4479 screen_start(); // don't know where cursor is now |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4480 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4481 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4482 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4483 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4484 * List of terminal codes that are currently recognized. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4485 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4486 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4487 static struct termcode |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4488 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4489 char_u name[2]; // termcap name of entry |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4490 char_u *code; // terminal code (in allocated memory) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4491 int len; // STRLEN(code) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4492 int modlen; // length of part before ";*~". |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4493 } *termcodes = NULL; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4494 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4495 static int tc_max_len = 0; // number of entries that termcodes[] can hold |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4496 static int tc_len = 0; // current number of entries in termcodes[] |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4497 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4498 static int termcode_star(char_u *code, int len); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4499 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4500 void |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4501 clear_termcodes(void) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4502 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4503 while (tc_len > 0) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4504 vim_free(termcodes[--tc_len].code); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4505 VIM_CLEAR(termcodes); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4506 tc_max_len = 0; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4507 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4508 #ifdef HAVE_TGETENT |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4509 BC = (char *)empty_option; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4510 UP = (char *)empty_option; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4511 PC = NUL; // set pad character to NUL |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4512 ospeed = 0; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4513 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4514 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4515 need_gather = TRUE; // need to fill termleader[] |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4516 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4517 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4518 #define ATC_FROM_TERM 55 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4519 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4520 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4521 * For xterm we recognize special codes like "ESC[42;*X" and "ESC O*X" that |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4522 * accept modifiers. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4523 * Set "termcodes[idx].modlen". |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4524 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4525 static void |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4526 adjust_modlen(int idx) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4527 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4528 termcodes[idx].modlen = 0; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4529 int j = termcode_star(termcodes[idx].code, termcodes[idx].len); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4530 if (j <= 0) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4531 return; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4532 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4533 termcodes[idx].modlen = termcodes[idx].len - 1 - j; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4534 // For "CSI[@;X" the "@" is not included in "modlen". |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4535 if (termcodes[idx].code[termcodes[idx].modlen - 1] == '@') |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4536 --termcodes[idx].modlen; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4537 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4538 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4539 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4540 * Add a new entry for "name[2]" to the list of terminal codes. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4541 * Note that "name" may not have a terminating NUL. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4542 * The list is kept alphabetical for ":set termcap" |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4543 * "flags" is TRUE when replacing 7-bit by 8-bit controls is desired. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4544 * "flags" can also be ATC_FROM_TERM for got_code_from_term(). |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4545 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4546 void |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4547 add_termcode(char_u *name, char_u *string, int flags) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4548 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4549 struct termcode *new_tc; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4550 int i, j; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4551 char_u *s; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4552 int len; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4553 #ifdef FEAT_EVAL |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4554 char *action = "Setting"; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4555 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4556 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4557 if (string == NULL || *string == NUL) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4558 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4559 del_termcode(name); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4560 return; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4561 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4562 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4563 #if defined(MSWIN) && !defined(FEAT_GUI) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4564 s = vim_strnsave(string, STRLEN(string) + 1); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4565 #else |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4566 # ifdef VIMDLL |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4567 if (!gui.in_use) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4568 s = vim_strnsave(string, STRLEN(string) + 1); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4569 else |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4570 # endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4571 s = vim_strsave(string); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4572 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4573 if (s == NULL) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4574 return; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4575 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4576 // Change leading <Esc>[ to CSI, change <Esc>O to <M-O>. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4577 if (flags != 0 && flags != ATC_FROM_TERM && term_7to8bit(string) != 0) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4578 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4579 STRMOVE(s, s + 1); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4580 s[0] = term_7to8bit(string); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4581 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4582 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4583 #if defined(MSWIN) && (!defined(FEAT_GUI) || defined(VIMDLL)) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4584 # ifdef VIMDLL |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4585 if (!gui.in_use) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4586 # endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4587 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4588 if (s[0] == K_NUL) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4589 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4590 STRMOVE(s + 1, s); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4591 s[1] = 3; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4592 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4593 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4594 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4595 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4596 len = (int)STRLEN(s); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4597 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4598 need_gather = TRUE; // need to fill termleader[] |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4599 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4600 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4601 * need to make space for more entries |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4602 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4603 if (tc_len == tc_max_len) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4604 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4605 tc_max_len += 20; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4606 new_tc = ALLOC_MULT(struct termcode, tc_max_len); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4607 if (new_tc == NULL) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4608 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4609 tc_max_len -= 20; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4610 vim_free(s); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4611 return; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4612 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4613 for (i = 0; i < tc_len; ++i) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4614 new_tc[i] = termcodes[i]; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4615 vim_free(termcodes); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4616 termcodes = new_tc; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4617 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4618 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4619 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4620 * Look for existing entry with the same name, it is replaced. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4621 * Look for an existing entry that is alphabetical higher, the new entry |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4622 * is inserted in front of it. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4623 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4624 for (i = 0; i < tc_len; ++i) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4625 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4626 if (termcodes[i].name[0] < name[0]) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4627 continue; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4628 if (termcodes[i].name[0] == name[0]) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4629 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4630 if (termcodes[i].name[1] < name[1]) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4631 continue; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4632 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4633 * Exact match: May replace old code. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4634 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4635 if (termcodes[i].name[1] == name[1]) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4636 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4637 if (flags == ATC_FROM_TERM && (j = termcode_star( |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4638 termcodes[i].code, termcodes[i].len)) > 0) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4639 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4640 // Don't replace ESC[123;*X or ESC O*X with another when |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4641 // invoked from got_code_from_term(). |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4642 if (len == termcodes[i].len - j |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4643 && STRNCMP(s, termcodes[i].code, len - 1) == 0 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4644 && s[len - 1] |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4645 == termcodes[i].code[termcodes[i].len - 1]) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4646 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4647 // They are equal but for the ";*": don't add it. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4648 #ifdef FEAT_EVAL |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4649 ch_log(NULL, "Termcap entry %c%c did not change", |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4650 name[0], name[1]); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4651 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4652 vim_free(s); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4653 return; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4654 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4655 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4656 else |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4657 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4658 // Replace old code. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4659 #ifdef FEAT_EVAL |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4660 ch_log(NULL, "Termcap entry %c%c was: %s", |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4661 name[0], name[1], termcodes[i].code); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4662 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4663 vim_free(termcodes[i].code); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4664 --tc_len; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4665 break; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4666 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4667 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4668 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4669 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4670 * Found alphabetical larger entry, move rest to insert new entry |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4671 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4672 #ifdef FEAT_EVAL |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4673 action = "Adding"; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4674 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4675 for (j = tc_len; j > i; --j) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4676 termcodes[j] = termcodes[j - 1]; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4677 break; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4678 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4679 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4680 #ifdef FEAT_EVAL |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4681 ch_log(NULL, "%s termcap entry %c%c to %s", action, name[0], name[1], s); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4682 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4683 termcodes[i].name[0] = name[0]; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4684 termcodes[i].name[1] = name[1]; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4685 termcodes[i].code = s; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4686 termcodes[i].len = len; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4687 adjust_modlen(i); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4688 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4689 ++tc_len; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4690 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4691 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4692 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4693 * Some function keys may include modifiers, but the terminfo/termcap entries |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4694 * do not indicate that. Insert ";*" where we expect modifiers might appear. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4695 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4696 static void |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4697 accept_modifiers_for_function_keys(void) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4698 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4699 regmatch_T regmatch; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4700 CLEAR_FIELD(regmatch); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4701 regmatch.rm_ic = TRUE; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4702 regmatch.regprog = vim_regcomp((char_u *)"^\033[\\d\\+\\~$", RE_MAGIC); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4703 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4704 for (int i = 0; i < tc_len; ++i) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4705 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4706 if (regmatch.regprog == NULL) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4707 return; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4708 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4709 // skip PasteStart and PasteEnd |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4710 if (termcodes[i].name[0] == 'P' |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4711 && (termcodes[i].name[1] == 'S' || termcodes[i].name[1] == 'E')) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4712 continue; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4713 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4714 char_u *s = termcodes[i].code; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4715 if (s != NULL && vim_regexec(®match, s, (colnr_T)0)) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4716 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4717 size_t len = STRLEN(s); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4718 char_u *ns = alloc(len + 3); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4719 if (ns != NULL) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4720 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4721 mch_memmove(ns, s, len - 1); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4722 mch_memmove(ns + len - 1, ";*~", 4); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4723 vim_free(s); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4724 termcodes[i].code = ns; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4725 termcodes[i].len += 2; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4726 adjust_modlen(i); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4727 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4728 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4729 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4730 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4731 vim_regfree(regmatch.regprog); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4732 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4733 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4734 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4735 * Check termcode "code[len]" for ending in ;*X or *X. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4736 * The "X" can be any character. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4737 * Return 0 if not found, 2 for ;*X and 1 for *X. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4738 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4739 static int |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4740 termcode_star(char_u *code, int len) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4741 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4742 // Shortest is <M-O>*X. With ; shortest is <CSI>@;*X |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4743 if (len >= 3 && code[len - 2] == '*') |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4744 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4745 if (len >= 5 && code[len - 3] == ';') |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4746 return 2; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4747 else |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4748 return 1; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4749 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4750 return 0; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4751 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4752 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4753 char_u * |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4754 find_termcode(char_u *name) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4755 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4756 int i; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4757 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4758 for (i = 0; i < tc_len; ++i) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4759 if (termcodes[i].name[0] == name[0] && termcodes[i].name[1] == name[1]) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4760 return termcodes[i].code; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4761 return NULL; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4762 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4763 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4764 char_u * |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4765 get_termcode(int i) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4766 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4767 if (i >= tc_len) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4768 return NULL; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4769 return &termcodes[i].name[0]; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4770 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4771 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4772 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4773 * Returns the length of the terminal code at index 'idx'. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4774 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4775 int |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4776 get_termcode_len(int idx) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4777 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4778 return termcodes[idx].len; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4779 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4780 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4781 void |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4782 del_termcode(char_u *name) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4783 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4784 int i; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4785 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4786 if (termcodes == NULL) // nothing there yet |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4787 return; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4788 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4789 need_gather = TRUE; // need to fill termleader[] |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4790 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4791 for (i = 0; i < tc_len; ++i) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4792 if (termcodes[i].name[0] == name[0] && termcodes[i].name[1] == name[1]) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4793 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4794 del_termcode_idx(i); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4795 return; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4796 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4797 // not found. Give error message? |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4798 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4799 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4800 static void |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4801 del_termcode_idx(int idx) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4802 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4803 int i; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4804 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4805 vim_free(termcodes[idx].code); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4806 --tc_len; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4807 for (i = idx; i < tc_len; ++i) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4808 termcodes[i] = termcodes[i + 1]; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4809 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4810 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4811 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4812 * Called when detected that the terminal sends 8-bit codes. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4813 * Convert all 7-bit codes to their 8-bit equivalent. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4814 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4815 static void |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4816 switch_to_8bit(void) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4817 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4818 int i; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4819 int c; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4820 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4821 // Only need to do something when not already using 8-bit codes. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4822 if (!term_is_8bit(T_NAME)) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4823 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4824 for (i = 0; i < tc_len; ++i) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4825 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4826 c = term_7to8bit(termcodes[i].code); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4827 if (c != 0) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4828 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4829 STRMOVE(termcodes[i].code + 1, termcodes[i].code + 2); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4830 termcodes[i].code[0] = c; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4831 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4832 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4833 need_gather = TRUE; // need to fill termleader[] |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4834 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4835 detected_8bit = TRUE; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4836 LOG_TR(("Switching to 8 bit")); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4837 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4838 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4839 #ifdef CHECK_DOUBLE_CLICK |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4840 static linenr_T orig_topline = 0; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4841 # ifdef FEAT_DIFF |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4842 static int orig_topfill = 0; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4843 # endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4844 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4845 #if defined(CHECK_DOUBLE_CLICK) || defined(PROTO) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4846 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4847 * Checking for double-clicks ourselves. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4848 * "orig_topline" is used to avoid detecting a double-click when the window |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4849 * contents scrolled (e.g., when 'scrolloff' is non-zero). |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4850 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4851 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4852 * Set orig_topline. Used when jumping to another window, so that a double |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4853 * click still works. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4854 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4855 void |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4856 set_mouse_topline(win_T *wp) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4857 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4858 orig_topline = wp->w_topline; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4859 # ifdef FEAT_DIFF |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4860 orig_topfill = wp->w_topfill; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4861 # endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4862 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4863 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4864 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4865 * Returns TRUE if the top line and top fill of window 'wp' matches the saved |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4866 * topline and topfill. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4867 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4868 int |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4869 is_mouse_topline(win_T *wp) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4870 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4871 return orig_topline == wp->w_topline |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4872 #ifdef FEAT_DIFF |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4873 && orig_topfill == wp->w_topfill |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4874 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4875 ; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4876 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4877 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4878 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4879 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4880 * If "buf" is NULL put "string[new_slen]" in typebuf; "buflen" is not used. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4881 * If "buf" is not NULL put "string[new_slen]" in "buf[bufsize]" and adjust |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4882 * "buflen". |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4883 * Remove "slen" bytes. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4884 * Returns FAIL for error. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4885 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4886 int |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4887 put_string_in_typebuf( |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4888 int offset, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4889 int slen, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4890 char_u *string, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4891 int new_slen, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4892 char_u *buf, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4893 int bufsize, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4894 int *buflen) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4895 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4896 int extra = new_slen - slen; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4897 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4898 string[new_slen] = NUL; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4899 if (buf == NULL) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4900 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4901 if (extra < 0) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4902 // remove matched chars, taking care of noremap |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4903 del_typebuf(-extra, offset); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4904 else if (extra > 0) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4905 // insert the extra space we need |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4906 if (ins_typebuf(string + slen, REMAP_YES, offset, FALSE, FALSE) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4907 == FAIL) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4908 return FAIL; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4909 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4910 // Careful: del_typebuf() and ins_typebuf() may have reallocated |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4911 // typebuf.tb_buf[]! |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4912 mch_memmove(typebuf.tb_buf + typebuf.tb_off + offset, string, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4913 (size_t)new_slen); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4914 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4915 else |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4916 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4917 if (extra < 0) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4918 // remove matched characters |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4919 mch_memmove(buf + offset, buf + offset - extra, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4920 (size_t)(*buflen + offset + extra)); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4921 else if (extra > 0) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4922 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4923 // Insert the extra space we need. If there is insufficient |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4924 // space return -1. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4925 if (*buflen + extra + new_slen >= bufsize) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4926 return FAIL; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4927 mch_memmove(buf + offset + extra, buf + offset, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4928 (size_t)(*buflen - offset)); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4929 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4930 mch_memmove(buf + offset, string, (size_t)new_slen); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4931 *buflen = *buflen + extra + new_slen; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4932 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4933 return OK; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4934 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4935 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4936 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4937 * Decode a modifier number as xterm provides it into MOD_MASK bits. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4938 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4939 int |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4940 decode_modifiers(int n) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4941 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4942 int code = n - 1; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4943 int modifiers = 0; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4944 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4945 if (code & 1) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4946 modifiers |= MOD_MASK_SHIFT; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4947 if (code & 2) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4948 modifiers |= MOD_MASK_ALT; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4949 if (code & 4) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4950 modifiers |= MOD_MASK_CTRL; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4951 if (code & 8) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4952 modifiers |= MOD_MASK_META; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4953 // Any further modifiers are silently dropped. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4954 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4955 return modifiers; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4956 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4957 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4958 static int |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4959 modifiers2keycode(int modifiers, int *key, char_u *string) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4960 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4961 int new_slen = 0; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4962 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4963 if (modifiers == 0) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4964 return 0; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4965 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4966 // Some keys have the modifier included. Need to handle that here to |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4967 // make mappings work. This may result in a special key, such as |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4968 // K_S_TAB. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4969 *key = simplify_key(*key, &modifiers); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4970 if (modifiers != 0) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4971 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4972 string[new_slen++] = K_SPECIAL; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4973 string[new_slen++] = (int)KS_MODIFIER; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4974 string[new_slen++] = modifiers; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4975 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4976 return new_slen; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4977 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4978 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4979 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4980 * Handle a cursor position report. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4981 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4982 static void |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4983 handle_u7_response(int *arg, char_u *tp UNUSED, int csi_len UNUSED) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4984 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4985 if (arg[0] == 2 && arg[1] >= 2) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4986 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4987 char *aw = NULL; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4988 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4989 LOG_TR(("Received U7 status: %s", tp)); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4990 u7_status.tr_progress = STATUS_GOT; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4991 did_cursorhold = TRUE; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4992 if (arg[1] == 2) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4993 aw = "single"; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4994 else if (arg[1] == 3) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4995 aw = "double"; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4996 if (aw != NULL && STRCMP(aw, p_ambw) != 0) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4997 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4998 // Setting the option causes a screen redraw. Do |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
4999 // that right away if possible, keeping any |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5000 // messages. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5001 set_option_value_give_err((char_u *)"ambw", 0L, (char_u *)aw, 0); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5002 #ifdef DEBUG_TERMRESPONSE |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5003 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5004 int r = redraw_asap(UPD_CLEAR); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5005 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5006 log_tr("set 'ambiwidth', redraw_asap(): %d", r); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5007 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5008 #else |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5009 redraw_asap(UPD_CLEAR); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5010 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5011 #ifdef FEAT_EVAL |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5012 set_vim_var_string(VV_TERMU7RESP, tp, csi_len); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5013 #endif |
34132
8f94a72dfbed
patch 9.1.0029: Cannot act on various terminal response codes
Christian Brabandt <cb@256bit.org>
parents:
34074
diff
changeset
|
5014 apply_autocmds(EVENT_TERMRESPONSEALL, |
8f94a72dfbed
patch 9.1.0029: Cannot act on various terminal response codes
Christian Brabandt <cb@256bit.org>
parents:
34074
diff
changeset
|
5015 (char_u *)"ambiguouswidth", NULL, FALSE, curbuf); |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5016 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5017 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5018 else if (arg[0] == 3) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5019 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5020 int value; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5021 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5022 LOG_TR(("Received compatibility test result: %s", tp)); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5023 xcc_status.tr_progress = STATUS_GOT; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5024 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5025 // Third row: xterm compatibility test. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5026 // If the cursor is on the first column then the terminal can handle |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5027 // the request for cursor style and blinking. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5028 value = arg[1] == 1 ? TPR_YES : TPR_NO; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5029 term_props[TPR_CURSOR_STYLE].tpr_status = value; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5030 term_props[TPR_CURSOR_BLINK].tpr_status = value; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5031 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5032 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5033 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5034 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5035 * Handle a response to T_CRV: {lead}{first}{x};{vers};{y}c |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5036 * Xterm and alike use '>' for {first}. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5037 * Rxvt sends "{lead}?1;2c". |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5038 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5039 static void |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5040 handle_version_response(int first, int *arg, int argc, char_u *tp) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5041 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5042 // The xterm version. It is set to zero when it can't be an actual xterm |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5043 // version. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5044 int version = arg[1]; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5045 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5046 LOG_TR(("Received CRV response: %s", tp)); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5047 crv_status.tr_progress = STATUS_GOT; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5048 did_cursorhold = TRUE; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5049 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5050 // Reset terminal properties that are set based on the termresponse. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5051 // Mainly useful for tests that send the termresponse multiple times. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5052 // For testing all props can be reset. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5053 init_term_props( |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5054 #ifdef FEAT_EVAL |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5055 reset_term_props_on_termresponse |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5056 #else |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5057 FALSE |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5058 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5059 ); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5060 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5061 // If this code starts with CSI, you can bet that the |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5062 // terminal uses 8-bit codes. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5063 if (tp[0] == CSI) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5064 switch_to_8bit(); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5065 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5066 // Screen sends 40500. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5067 // rxvt sends its version number: "20703" is 2.7.3. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5068 // Ignore it for when the user has set 'term' to xterm, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5069 // even though it's an rxvt. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5070 if (version > 20000) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5071 version = 0; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5072 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5073 // Figure out more if the response is CSI > 99 ; 99 ; 99 c |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5074 if (first == '>' && argc == 3) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5075 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5076 // mintty 2.9.5 sends 77;20905;0c. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5077 // (77 is ASCII 'M' for mintty.) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5078 if (arg[0] == 77) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5079 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5080 // mintty can do SGR mouse reporting |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5081 term_props[TPR_MOUSE].tpr_status = TPR_MOUSE_SGR; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5082 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5083 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5084 #ifdef FEAT_TERMRESPONSE |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5085 // If xterm version >= 141 try to get termcap codes. For other |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5086 // terminals the request should be ignored. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5087 if (version >= 141 && p_xtermcodes) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5088 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5089 LOG_TR(("Enable checking for XT codes")); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5090 check_for_codes = TRUE; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5091 need_gather = TRUE; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5092 req_codes_from_term(); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5093 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5094 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5095 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5096 // libvterm sends 0;100;0 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5097 // Konsole sends 0;115;0 and works the same way |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5098 if ((version == 100 || version == 115) && arg[0] == 0 && arg[2] == 0) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5099 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5100 // If run from Vim $COLORS is set to the number of |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5101 // colors the terminal supports. Otherwise assume |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5102 // 256, libvterm supports even more. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5103 if (mch_getenv((char_u *)"COLORS") == NULL) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5104 may_adjust_color_count(256); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5105 // Libvterm can handle SGR mouse reporting. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5106 term_props[TPR_MOUSE].tpr_status = TPR_MOUSE_SGR; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5107 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5108 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5109 if (version == 95) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5110 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5111 // Mac Terminal.app sends 1;95;0 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5112 if (arg[0] == 1 && arg[2] == 0) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5113 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5114 term_props[TPR_UNDERLINE_RGB].tpr_status = TPR_YES; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5115 term_props[TPR_MOUSE].tpr_status = TPR_MOUSE_SGR; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5116 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5117 // iTerm2 sends 0;95;0 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5118 else if (arg[0] == 0 && arg[2] == 0) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5119 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5120 // iTerm2 can do SGR mouse reporting |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5121 term_props[TPR_MOUSE].tpr_status = TPR_MOUSE_SGR; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5122 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5123 // old iTerm2 sends 0;95; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5124 else if (arg[0] == 0 && arg[2] == -1) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5125 term_props[TPR_UNDERLINE_RGB].tpr_status = TPR_YES; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5126 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5127 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5128 // screen sends 83;40500;0 83 is 'S' in ASCII. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5129 if (arg[0] == 83) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5130 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5131 // screen supports SGR mouse codes since 4.7.0 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5132 if (arg[1] >= 40700) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5133 term_props[TPR_MOUSE].tpr_status = TPR_MOUSE_SGR; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5134 else |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5135 term_props[TPR_MOUSE].tpr_status = TPR_MOUSE_XTERM; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5136 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5137 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5138 // If no recognized terminal has set mouse behavior, assume xterm. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5139 if (term_props[TPR_MOUSE].tpr_status == TPR_UNKNOWN) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5140 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5141 // Xterm version 277 supports SGR. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5142 // Xterm version >= 95 supports mouse dragging. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5143 if (version >= 277) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5144 term_props[TPR_MOUSE].tpr_status = TPR_MOUSE_SGR; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5145 else if (version >= 95) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5146 term_props[TPR_MOUSE].tpr_status = TPR_MOUSE_XTERM2; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5147 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5148 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5149 // Detect terminals that set $TERM to something like |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5150 // "xterm-256color" but are not fully xterm compatible. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5151 // |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5152 // Gnome terminal sends 1;3801;0, 1;4402;0 or 1;2501;0. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5153 // Newer Gnome-terminal sends 65;6001;1. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5154 // xfce4-terminal sends 1;2802;0. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5155 // screen sends 83;40500;0 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5156 // Assuming any version number over 2500 is not an |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5157 // xterm (without the limit for rxvt and screen). |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5158 if (arg[1] >= 2500) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5159 term_props[TPR_UNDERLINE_RGB].tpr_status = TPR_YES; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5160 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5161 else if (version == 136 && arg[2] == 0) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5162 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5163 term_props[TPR_UNDERLINE_RGB].tpr_status = TPR_YES; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5164 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5165 // PuTTY sends 0;136;0 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5166 if (arg[0] == 0) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5167 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5168 // supports sgr-like mouse reporting. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5169 term_props[TPR_MOUSE].tpr_status = TPR_MOUSE_SGR; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5170 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5171 // vandyke SecureCRT sends 1;136;0 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5172 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5173 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5174 // Konsole sends 0;115;0 - but t_u8 does not actually work, therefore |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5175 // commented out. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5176 // else if (version == 115 && arg[0] == 0 && arg[2] == 0) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5177 // term_props[TPR_UNDERLINE_RGB].tpr_status = TPR_YES; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5178 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5179 // Kitty up to 9.x sends 1;400{version};{secondary-version} |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5180 if (arg[0] == 1 && arg[1] >= 4000 && arg[1] <= 4009) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5181 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5182 term_props[TPR_KITTY].tpr_status = TPR_YES; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5183 term_props[TPR_KITTY].tpr_set_by_termresponse = TRUE; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5184 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5185 // Kitty can handle SGR mouse reporting. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5186 term_props[TPR_MOUSE].tpr_status = TPR_MOUSE_SGR; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5187 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5188 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5189 // GNU screen sends 83;30600;0, 83;40500;0, etc. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5190 // 30600/40500 is a version number of GNU screen. DA2 support is added |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5191 // on 3.6. DCS string has a special meaning to GNU screen, but xterm |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5192 // compatibility checking does not detect GNU screen. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5193 if (arg[0] == 83 && arg[1] >= 30600) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5194 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5195 term_props[TPR_CURSOR_STYLE].tpr_status = TPR_NO; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5196 term_props[TPR_CURSOR_BLINK].tpr_status = TPR_NO; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5197 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5198 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5199 // Xterm first responded to this request at patch level |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5200 // 95, so assume anything below 95 is not xterm and hopefully supports |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5201 // the underline RGB color sequence. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5202 if (version < 95) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5203 term_props[TPR_UNDERLINE_RGB].tpr_status = TPR_YES; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5204 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5205 // Getting the cursor style is only supported properly by xterm since |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5206 // version 279 (otherwise it returns 0x18). |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5207 if (version < 279) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5208 term_props[TPR_CURSOR_STYLE].tpr_status = TPR_NO; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5209 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5210 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5211 * Take action on the detected properties. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5212 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5213 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5214 // Unless the underline RGB color is expected to work, disable "t_8u". |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5215 // It does not work for the real Xterm, it resets the background color. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5216 // This may cause some flicker. Alternative would be to set "t_8u" |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5217 // here if the terminal is expected to support it, but that might |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5218 // conflict with what was set in the .vimrc. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5219 if (term_props[TPR_UNDERLINE_RGB].tpr_status != TPR_YES |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5220 && *T_8U != NUL |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5221 && !option_was_set((char_u *)"t_8u")) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5222 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5223 set_string_option_direct((char_u *)"t_8u", -1, (char_u *)"", |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5224 OPT_FREE, 0); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5225 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5226 #ifdef FEAT_TERMRESPONSE |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5227 if (*T_8U != NUL && write_t_8u_state == MAYBE) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5228 // Did skip writing t_8u, a complete redraw is needed. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5229 redraw_later_clear(); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5230 write_t_8u_state = OK; // can output t_8u now |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5231 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5232 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5233 // Only set 'ttymouse' automatically if it was not set |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5234 // by the user already. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5235 if (!option_was_set((char_u *)"ttym") |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5236 && (term_props[TPR_MOUSE].tpr_status == TPR_MOUSE_XTERM2 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5237 || term_props[TPR_MOUSE].tpr_status == TPR_MOUSE_SGR)) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5238 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5239 set_option_value_give_err((char_u *)"ttym", 0L, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5240 term_props[TPR_MOUSE].tpr_status == TPR_MOUSE_SGR |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5241 ? (char_u *)"sgr" : (char_u *)"xterm2", 0); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5242 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5243 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5244 #ifdef FEAT_TERMRESPONSE |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5245 int need_flush = FALSE; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5246 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5247 // Only request the cursor style if t_SH and t_RS are |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5248 // set. Only supported properly by xterm since version |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5249 // 279 (otherwise it returns 0x18). |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5250 // Only when getting the cursor style was detected to work. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5251 // Not for Terminal.app, it can't handle t_RS, it |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5252 // echoes the characters to the screen. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5253 if (rcs_status.tr_progress == STATUS_GET |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5254 && term_props[TPR_CURSOR_STYLE].tpr_status == TPR_YES |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5255 && *T_CSH != NUL |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5256 && *T_CRS != NUL) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5257 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5258 MAY_WANT_TO_LOG_THIS; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5259 LOG_TR(("Sending cursor style request")); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5260 out_str(T_CRS); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5261 termrequest_sent(&rcs_status); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5262 need_flush = TRUE; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5263 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5264 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5265 // Only request the cursor blink mode if t_RC set. Not |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5266 // for Gnome terminal, it can't handle t_RC, it |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5267 // echoes the characters to the screen. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5268 // Only when getting the cursor style was detected to work. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5269 if (rbm_status.tr_progress == STATUS_GET |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5270 && term_props[TPR_CURSOR_BLINK].tpr_status == TPR_YES |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5271 && *T_CRC != NUL) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5272 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5273 MAY_WANT_TO_LOG_THIS; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5274 LOG_TR(("Sending cursor blink mode request")); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5275 out_str(T_CRC); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5276 termrequest_sent(&rbm_status); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5277 need_flush = TRUE; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5278 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5279 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5280 if (need_flush) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5281 out_flush(); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5282 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5283 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5284 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5285 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5286 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5287 * Add "key" to "buf" and return the number of bytes used. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5288 * Handles special keys and multi-byte characters. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5289 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5290 static int |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5291 add_key_to_buf(int key, char_u *buf) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5292 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5293 int idx = 0; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5294 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5295 if (IS_SPECIAL(key)) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5296 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5297 buf[idx++] = K_SPECIAL; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5298 buf[idx++] = KEY2TERMCAP0(key); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5299 buf[idx++] = KEY2TERMCAP1(key); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5300 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5301 else if (has_mbyte) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5302 idx += (*mb_char2bytes)(key, buf + idx); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5303 else |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5304 buf[idx++] = key; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5305 return idx; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5306 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5307 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5308 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5309 * Shared between handle_key_with_modifier() and handle_csi_function_key(). |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5310 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5311 static int |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5312 put_key_modifiers_in_typebuf( |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5313 int key_arg, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5314 int modifiers_arg, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5315 int csi_len, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5316 int offset, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5317 char_u *buf, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5318 int bufsize, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5319 int *buflen) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5320 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5321 int key = key_arg; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5322 int modifiers = modifiers_arg; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5323 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5324 // Some keys need adjustment when the Ctrl modifier is used. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5325 key = may_adjust_key_for_ctrl(modifiers, key); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5326 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5327 // May remove the shift modifier if it's already included in the key. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5328 modifiers = may_remove_shift_modifier(modifiers, key); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5329 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5330 // Produce modifiers with K_SPECIAL KS_MODIFIER {mod} |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5331 char_u string[MAX_KEY_CODE_LEN + 1]; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5332 int new_slen = modifiers2keycode(modifiers, &key, string); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5333 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5334 // Add the bytes for the key. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5335 new_slen += add_key_to_buf(key, string + new_slen); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5336 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5337 string[new_slen] = NUL; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5338 if (put_string_in_typebuf(offset, csi_len, string, new_slen, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5339 buf, bufsize, buflen) == FAIL) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5340 return -1; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5341 return new_slen - csi_len + offset; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5342 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5343 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5344 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5345 * Handle a sequence with key and modifier, one of: |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5346 * {lead}27;{modifier};{key}~ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5347 * {lead}{key};{modifier}u |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5348 * Returns the difference in length. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5349 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5350 static int |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5351 handle_key_with_modifier( |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5352 int *arg, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5353 int trail, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5354 int csi_len, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5355 int offset, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5356 char_u *buf, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5357 int bufsize, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5358 int *buflen) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5359 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5360 // Only set seenModifyOtherKeys for the "{lead}27;" code to avoid setting |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5361 // it for terminals using the kitty keyboard protocol. Xterm sends |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5362 // the form ending in "u" when the formatOtherKeys resource is set. We do |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5363 // not support this. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5364 // |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5365 // Do not set seenModifyOtherKeys if there was a positive response at any |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5366 // time from requesting the kitty keyboard protocol state, these are not |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5367 // expected to support modifyOtherKeys level 2. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5368 // |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5369 // Do not set seenModifyOtherKeys for kitty, it does send some sequences |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5370 // like this but does not have the modifyOtherKeys feature. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5371 if (trail != 'u' |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5372 && (kitty_protocol_state == KKPS_INITIAL |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5373 || kitty_protocol_state == KKPS_OFF |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5374 || kitty_protocol_state == KKPS_AFTER_T_TE) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5375 && term_props[TPR_KITTY].tpr_status != TPR_YES) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5376 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5377 #ifdef FEAT_EVAL |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5378 ch_log(NULL, "setting seenModifyOtherKeys to TRUE"); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5379 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5380 seenModifyOtherKeys = TRUE; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5381 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5382 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5383 int key = trail == 'u' ? arg[0] : arg[2]; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5384 int modifiers = decode_modifiers(arg[1]); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5385 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5386 // Some terminals do not apply the Shift modifier to the key. To make |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5387 // mappings consistent we do it here. TODO: support more keys. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5388 if ((modifiers & MOD_MASK_SHIFT) && key >= 'a' && key <= 'z') |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5389 key += 'A' - 'a'; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5390 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5391 // Putting Esc in the buffer creates ambiguity, it can be the start of an |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5392 // escape sequence. Use K_ESC to avoid that. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5393 if (key == ESC) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5394 key = K_ESC; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5395 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5396 return put_key_modifiers_in_typebuf(key, modifiers, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5397 csi_len, offset, buf, bufsize, buflen); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5398 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5399 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5400 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5401 * Handle a sequence with key without a modifier: |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5402 * {lead}{key}u |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5403 * Returns the difference in length. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5404 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5405 static int |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5406 handle_key_without_modifier( |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5407 int *arg, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5408 int csi_len, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5409 int offset, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5410 char_u *buf, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5411 int bufsize, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5412 int *buflen) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5413 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5414 char_u string[MAX_KEY_CODE_LEN + 1]; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5415 int new_slen; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5416 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5417 if (arg[0] == ESC) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5418 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5419 // Putting Esc in the buffer creates ambiguity, it can be the start of |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5420 // an escape sequence. Use K_ESC to avoid that. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5421 string[0] = K_SPECIAL; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5422 string[1] = KS_EXTRA; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5423 string[2] = KE_ESC; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5424 new_slen = 3; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5425 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5426 else |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5427 new_slen = add_key_to_buf(arg[0], string); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5428 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5429 if (put_string_in_typebuf(offset, csi_len, string, new_slen, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5430 buf, bufsize, buflen) == FAIL) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5431 return -1; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5432 return new_slen - csi_len + offset; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5433 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5434 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5435 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5436 * CSI function key without or with modifiers: |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5437 * {lead}[ABCDEFHPQRS] |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5438 * {lead}1;{modifier}[ABCDEFHPQRS] |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5439 * Returns zero when nog recognized, a positive number when recognized. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5440 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5441 static int |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5442 handle_csi_function_key( |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5443 int argc, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5444 int *arg, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5445 int trail, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5446 int csi_len, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5447 char_u *key_name, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5448 int offset, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5449 char_u *buf, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5450 int bufsize, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5451 int *buflen) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5452 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5453 key_name[0] = 'k'; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5454 switch (trail) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5455 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5456 case 'A': key_name[1] = 'u'; break; // K_UP |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5457 case 'B': key_name[1] = 'd'; break; // K_DOWN |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5458 case 'C': key_name[1] = 'r'; break; // K_RIGHT |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5459 case 'D': key_name[1] = 'l'; break; // K_LEFT |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5460 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5461 // case 'E': keypad BEGIN - not supported |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5462 case 'F': key_name[0] = '@'; key_name[1] = '7'; break; // K_END |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5463 case 'H': key_name[1] = 'h'; break; // K_HOME |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5464 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5465 case 'P': key_name[1] = '1'; break; // K_F1 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5466 case 'Q': key_name[1] = '2'; break; // K_F2 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5467 case 'R': key_name[1] = '3'; break; // K_F3 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5468 case 'S': key_name[1] = '4'; break; // K_F4 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5469 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5470 default: return 0; // not recognized |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5471 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5472 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5473 int key = TERMCAP2KEY(key_name[0], key_name[1]); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5474 int modifiers = argc == 2 ? decode_modifiers(arg[1]) : 0; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5475 put_key_modifiers_in_typebuf(key, modifiers, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5476 csi_len, offset, buf, bufsize, buflen); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5477 return csi_len; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5478 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5479 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5480 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5481 * Handle a CSI escape sequence. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5482 * - Xterm version string. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5483 * |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5484 * - Response to XTQMODKEYS: "{lead} > 4 ; Pv m". |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5485 * |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5486 * - Cursor position report: {lead}{row};{col}R |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5487 * The final byte must be 'R'. It is used for checking the |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5488 * ambiguous-width character state. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5489 * |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5490 * - window position reply: {lead}3;{x};{y}t |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5491 * |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5492 * - key with modifiers when modifyOtherKeys is enabled or the Kitty keyboard |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5493 * protocol is used: |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5494 * {lead}27;{modifier};{key}~ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5495 * {lead}{key};{modifier}u |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5496 * |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5497 * - function key with or without modifiers: |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5498 * {lead}[ABCDEFHPQRS] |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5499 * {lead}1;{modifier}[ABCDEFHPQRS] |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5500 * |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5501 * Return 0 for no match, -1 for partial match, > 0 for full match. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5502 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5503 static int |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5504 handle_csi( |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5505 char_u *tp, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5506 int len, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5507 char_u *argp, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5508 int offset, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5509 char_u *buf, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5510 int bufsize, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5511 int *buflen, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5512 char_u *key_name, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5513 int *slen) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5514 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5515 int first = -1; // optional char right after {lead} |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5516 int trail; // char that ends CSI sequence |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5517 int arg[3] = {-1, -1, -1}; // argument numbers |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5518 int argc = 0; // number of arguments |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5519 char_u *ap = argp; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5520 int csi_len; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5521 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5522 // Check for non-digit after CSI. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5523 if (!VIM_ISDIGIT(*ap)) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5524 first = *ap++; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5525 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5526 if (first >= 'A' && first <= 'Z') |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5527 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5528 // If "first" is in [ABCDEFHPQRS] then it is actually the "trail" and |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5529 // no argument follows. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5530 trail = first; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5531 first = -1; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5532 --ap; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5533 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5534 else |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5535 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5536 // Find up to three argument numbers. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5537 for (argc = 0; argc < 3; ) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5538 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5539 if (ap >= tp + len) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5540 return -1; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5541 if (*ap == ';') |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5542 arg[argc++] = -1; // omitted number |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5543 else if (VIM_ISDIGIT(*ap)) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5544 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5545 arg[argc] = 0; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5546 for (;;) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5547 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5548 if (ap >= tp + len) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5549 return -1; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5550 if (!VIM_ISDIGIT(*ap)) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5551 break; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5552 arg[argc] = arg[argc] * 10 + (*ap - '0'); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5553 ++ap; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5554 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5555 ++argc; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5556 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5557 if (*ap == ';') |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5558 ++ap; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5559 else |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5560 break; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5561 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5562 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5563 // mrxvt has been reported to have "+" in the version. Assume |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5564 // the escape sequence ends with a letter or one of "{|}~". |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5565 while (ap < tp + len |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5566 && !(*ap >= '{' && *ap <= '~') |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5567 && !ASCII_ISALPHA(*ap)) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5568 ++ap; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5569 if (ap >= tp + len) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5570 return -1; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5571 trail = *ap; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5572 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5573 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5574 csi_len = (int)(ap - tp) + 1; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5575 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5576 // Response to XTQMODKEYS: "CSI > 4 ; Pv m" where Pv indicates the |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5577 // modifyOtherKeys level. Drop similar responses. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5578 if (first == '>' && (argc == 1 || argc == 2) && trail == 'm') |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5579 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5580 if (arg[0] == 4 && argc == 2) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5581 modify_otherkeys_state = arg[1] == 2 ? MOKS_ENABLED : MOKS_OFF; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5582 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5583 key_name[0] = (int)KS_EXTRA; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5584 key_name[1] = (int)KE_IGNORE; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5585 *slen = csi_len; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5586 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5587 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5588 // Function key starting with CSI: |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5589 // {lead}[ABCDEFHPQRS] |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5590 // {lead}1;{modifier}[ABCDEFHPQRS] |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5591 else if (first == -1 && ASCII_ISUPPER(trail) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5592 && (argc == 0 || (argc == 2 && arg[0] == 1))) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5593 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5594 int res = handle_csi_function_key(argc, arg, trail, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5595 csi_len, key_name, offset, buf, bufsize, buflen); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5596 return res <= 0 ? res : len + res; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5597 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5598 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5599 // Cursor position report: {lead}{row};{col}R |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5600 // Eat it when there are 2 arguments and it ends in 'R'. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5601 // Also when u7_status is not "sent", it may be from a previous Vim that |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5602 // just exited. But not for <S-F3>, it sends something similar, check for |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5603 // row and column to make sense. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5604 else if (first == -1 && argc == 2 && trail == 'R') |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5605 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5606 handle_u7_response(arg, tp, csi_len); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5607 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5608 key_name[0] = (int)KS_EXTRA; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5609 key_name[1] = (int)KE_IGNORE; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5610 *slen = csi_len; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5611 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5612 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5613 // Version string: Eat it when there is at least one digit and |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5614 // it ends in 'c' |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5615 else if (*T_CRV != NUL && ap > argp + 1 && trail == 'c') |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5616 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5617 handle_version_response(first, arg, argc, tp); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5618 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5619 *slen = csi_len; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5620 #ifdef FEAT_EVAL |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5621 set_vim_var_string(VV_TERMRESPONSE, tp, *slen); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5622 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5623 apply_autocmds(EVENT_TERMRESPONSE, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5624 NULL, NULL, FALSE, curbuf); |
34132
8f94a72dfbed
patch 9.1.0029: Cannot act on various terminal response codes
Christian Brabandt <cb@256bit.org>
parents:
34074
diff
changeset
|
5625 apply_autocmds(EVENT_TERMRESPONSEALL, |
8f94a72dfbed
patch 9.1.0029: Cannot act on various terminal response codes
Christian Brabandt <cb@256bit.org>
parents:
34074
diff
changeset
|
5626 (char_u *)"version", NULL, FALSE, curbuf); |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5627 key_name[0] = (int)KS_EXTRA; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5628 key_name[1] = (int)KE_IGNORE; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5629 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5630 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5631 #ifdef FEAT_TERMRESPONSE |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5632 // Check blinking cursor from xterm: |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5633 // {lead}?12;1$y set |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5634 // {lead}?12;2$y not set |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5635 // |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5636 // {lead} can be <Esc>[ or CSI |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5637 else if (rbm_status.tr_progress == STATUS_SENT |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5638 && first == '?' |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5639 && ap == argp + 6 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5640 && arg[0] == 12 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5641 && ap[-1] == '$' |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5642 && trail == 'y') |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5643 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5644 initial_cursor_blink = (arg[1] == '1'); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5645 rbm_status.tr_progress = STATUS_GOT; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5646 LOG_TR(("Received cursor blinking mode response: %s", tp)); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5647 key_name[0] = (int)KS_EXTRA; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5648 key_name[1] = (int)KE_IGNORE; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5649 *slen = csi_len; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5650 # ifdef FEAT_EVAL |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5651 set_vim_var_string(VV_TERMBLINKRESP, tp, *slen); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5652 # endif |
34132
8f94a72dfbed
patch 9.1.0029: Cannot act on various terminal response codes
Christian Brabandt <cb@256bit.org>
parents:
34074
diff
changeset
|
5653 apply_autocmds(EVENT_TERMRESPONSEALL, |
8f94a72dfbed
patch 9.1.0029: Cannot act on various terminal response codes
Christian Brabandt <cb@256bit.org>
parents:
34074
diff
changeset
|
5654 (char_u *)"cursorblink", NULL, FALSE, curbuf); |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5655 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5656 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5657 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5658 // Kitty keyboard protocol status response: CSI ? flags u |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5659 else if (first == '?' && argc == 1 && trail == 'u') |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5660 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5661 // The protocol has various "progressive enhancement flags" values, but |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5662 // we only check for zero and non-zero here. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5663 if (arg[0] == '0') |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5664 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5665 kitty_protocol_state = KKPS_OFF; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5666 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5667 else |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5668 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5669 kitty_protocol_state = KKPS_ENABLED; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5670 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5671 // Reset seenModifyOtherKeys just in case some key combination has |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5672 // been seen that set it before we get the status response. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5673 #ifdef FEAT_EVAL |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5674 ch_log(NULL, "setting seenModifyOtherKeys to FALSE"); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5675 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5676 seenModifyOtherKeys = FALSE; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5677 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5678 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5679 key_name[0] = (int)KS_EXTRA; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5680 key_name[1] = (int)KE_IGNORE; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5681 *slen = csi_len; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5682 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5683 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5684 #ifdef FEAT_TERMRESPONSE |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5685 // Check for a window position response from the terminal: |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5686 // {lead}3;{x};{y}t |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5687 else if (did_request_winpos && argc == 3 && arg[0] == 3 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5688 && trail == 't') |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5689 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5690 winpos_x = arg[1]; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5691 winpos_y = arg[2]; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5692 // got finished code: consume it |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5693 key_name[0] = (int)KS_EXTRA; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5694 key_name[1] = (int)KE_IGNORE; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5695 *slen = csi_len; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5696 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5697 if (--did_request_winpos <= 0) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5698 winpos_status.tr_progress = STATUS_GOT; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5699 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5700 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5701 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5702 // Key with modifier: |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5703 // {lead}27;{modifier};{key}~ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5704 // {lead}{key};{modifier}u |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5705 // Even though we only handle four modifiers and the {modifier} value |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5706 // should be 16 or lower, we accept all modifier values to avoid the raw |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5707 // sequence to be passed through. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5708 else if ((arg[0] == 27 && argc == 3 && trail == '~') |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5709 || (argc == 2 && trail == 'u')) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5710 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5711 return len + handle_key_with_modifier(arg, trail, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5712 csi_len, offset, buf, bufsize, buflen); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5713 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5714 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5715 // Key without modifier (Kitty sends this for Esc): |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5716 // {lead}{key}u |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5717 else if (argc == 1 && trail == 'u') |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5718 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5719 return len + handle_key_without_modifier(arg, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5720 csi_len, offset, buf, bufsize, buflen); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5721 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5722 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5723 // else: Unknown CSI sequence. We could drop it, but then the |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5724 // user can't create a map for it. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5725 return 0; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5726 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5727 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5728 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5729 * Handle an OSC sequence, fore/background color response from the terminal: |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5730 * |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5731 * {lead}{code};rgb:{rrrr}/{gggg}/{bbbb}{tail} |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5732 * or {lead}{code};rgb:{rr}/{gg}/{bb}{tail} |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5733 * |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5734 * {code} is 10 for foreground, 11 for background |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5735 * {lead} can be <Esc>] or OSC |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5736 * {tail} can be '\007', <Esc>\ or STERM. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5737 * |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5738 * Consume any code that starts with "{lead}11;", it's also |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5739 * possible that "rgba" is following. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5740 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5741 static int |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5742 handle_osc(char_u *tp, char_u *argp, int len, char_u *key_name, int *slen) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5743 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5744 int i, j; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5745 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5746 j = 1 + (tp[0] == ESC); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5747 if (len >= j + 3 && (argp[0] != '1' |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5748 || (argp[1] != '1' && argp[1] != '0') |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5749 || argp[2] != ';')) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5750 i = 0; // no match |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5751 else |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5752 for (i = j; i < len; ++i) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5753 if (tp[i] == '\007' || (tp[0] == OSC ? tp[i] == STERM |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5754 : (tp[i] == ESC && i + 1 < len && tp[i + 1] == '\\'))) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5755 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5756 int is_bg = argp[1] == '1'; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5757 int is_4digit = i - j >= 21 && tp[j + 11] == '/' |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5758 && tp[j + 16] == '/'; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5759 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5760 if (i - j >= 15 && STRNCMP(tp + j + 3, "rgb:", 4) == 0 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5761 && (is_4digit |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5762 || (tp[j + 9] == '/' && tp[j + 12] == '/'))) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5763 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5764 char_u *tp_r = tp + j + 7; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5765 char_u *tp_g = tp + j + (is_4digit ? 12 : 10); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5766 char_u *tp_b = tp + j + (is_4digit ? 17 : 13); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5767 #if defined(FEAT_TERMRESPONSE) && defined(FEAT_TERMINAL) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5768 int rval, gval, bval; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5769 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5770 rval = hexhex2nr(tp_r); |
34312
737023edd0a5
patch 9.1.0090: Assigning wrong colors when parsing terminal OSC response
Christian Brabandt <cb@256bit.org>
parents:
34151
diff
changeset
|
5771 gval = hexhex2nr(tp_g); |
737023edd0a5
patch 9.1.0090: Assigning wrong colors when parsing terminal OSC response
Christian Brabandt <cb@256bit.org>
parents:
34151
diff
changeset
|
5772 bval = hexhex2nr(tp_b); |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5773 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5774 if (is_bg) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5775 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5776 char *new_bg_val = (3 * '6' < *tp_r + *tp_g + |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5777 *tp_b) ? "light" : "dark"; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5778 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5779 LOG_TR(("Received RBG response: %s", tp)); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5780 #ifdef FEAT_TERMRESPONSE |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5781 rbg_status.tr_progress = STATUS_GOT; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5782 # ifdef FEAT_TERMINAL |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5783 bg_r = rval; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5784 bg_g = gval; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5785 bg_b = bval; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5786 # endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5787 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5788 if (!option_was_set((char_u *)"bg") |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5789 && STRCMP(p_bg, new_bg_val) != 0) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5790 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5791 // value differs, apply it |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5792 set_option_value_give_err((char_u *)"bg", |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5793 0L, (char_u *)new_bg_val, 0); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5794 reset_option_was_set((char_u *)"bg"); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5795 redraw_asap(UPD_CLEAR); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5796 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5797 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5798 #if defined(FEAT_TERMRESPONSE) && defined(FEAT_TERMINAL) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5799 else |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5800 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5801 LOG_TR(("Received RFG response: %s", tp)); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5802 rfg_status.tr_progress = STATUS_GOT; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5803 fg_r = rval; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5804 fg_g = gval; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5805 fg_b = bval; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5806 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5807 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5808 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5809 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5810 // got finished code: consume it |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5811 key_name[0] = (int)KS_EXTRA; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5812 key_name[1] = (int)KE_IGNORE; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5813 *slen = i + 1 + (tp[i] == ESC); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5814 #ifdef FEAT_EVAL |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5815 set_vim_var_string(is_bg ? VV_TERMRBGRESP |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5816 : VV_TERMRFGRESP, tp, *slen); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5817 #endif |
34132
8f94a72dfbed
patch 9.1.0029: Cannot act on various terminal response codes
Christian Brabandt <cb@256bit.org>
parents:
34074
diff
changeset
|
5818 apply_autocmds(EVENT_TERMRESPONSEALL, |
8f94a72dfbed
patch 9.1.0029: Cannot act on various terminal response codes
Christian Brabandt <cb@256bit.org>
parents:
34074
diff
changeset
|
5819 is_bg ? (char_u *)"background" : (char_u *)"foreground", NULL, FALSE, curbuf); |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5820 break; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5821 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5822 if (i == len) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5823 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5824 LOG_TR(("not enough characters for RB")); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5825 return FAIL; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5826 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5827 return OK; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5828 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5829 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5830 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5831 * Check for key code response from xterm: |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5832 * {lead}{flag}+r<hex bytes><{tail} |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5833 * |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5834 * {lead} can be <Esc>P or DCS |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5835 * {flag} can be '0' or '1' |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5836 * {tail} can be Esc>\ or STERM |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5837 * |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5838 * Check for resource response from xterm (and drop it): |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5839 * {lead}{flag}+R<hex bytes>=<value>{tail} |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5840 * |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5841 * Check for cursor shape response from xterm: |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5842 * {lead}1$r<digit> q{tail} |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5843 * |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5844 * {lead} can be <Esc>P or DCS |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5845 * {tail} can be <Esc>\ or STERM |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5846 * |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5847 * Consume any code that starts with "{lead}.+r" or "{lead}.$r". |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5848 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5849 static int |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5850 handle_dcs(char_u *tp, char_u *argp, int len, char_u *key_name, int *slen) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5851 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5852 int i, j; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5853 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5854 j = 1 + (tp[0] == ESC); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5855 if (len < j + 3) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5856 i = len; // need more chars |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5857 else if ((argp[1] != '+' && argp[1] != '$') |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5858 || (argp[2] != 'r' && argp[2] != 'R')) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5859 i = 0; // no match |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5860 else if (argp[1] == '+') |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5861 // key code response |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5862 for (i = j; i < len; ++i) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5863 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5864 if ((tp[i] == ESC && i + 1 < len && tp[i + 1] == '\\') |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5865 || tp[i] == STERM) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5866 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5867 #ifdef FEAT_TERMRESPONSE |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5868 // handle a key code response, drop a resource response |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5869 if (i - j >= 3 && argp[2] == 'r') |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5870 got_code_from_term(tp + j, i); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5871 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5872 key_name[0] = (int)KS_EXTRA; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5873 key_name[1] = (int)KE_IGNORE; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5874 *slen = i + 1 + (tp[i] == ESC); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5875 break; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5876 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5877 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5878 else |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5879 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5880 // Probably the cursor shape response. Make sure that "i" |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5881 // is equal to "len" when there are not sufficient |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5882 // characters. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5883 for (i = j + 3; i < len; ++i) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5884 { |
34074
1629cc65d78d
patch 9.1.0006: is*() and to*() function may be unsafe
Christian Brabandt <cb@256bit.org>
parents:
33888
diff
changeset
|
5885 if (i - j == 3 && !SAFE_isdigit(tp[i])) |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5886 break; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5887 if (i - j == 4 && tp[i] != ' ') |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5888 break; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5889 if (i - j == 5 && tp[i] != 'q') |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5890 break; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5891 if (i - j == 6 && tp[i] != ESC && tp[i] != STERM) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5892 break; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5893 if ((i - j == 6 && tp[i] == STERM) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5894 || (i - j == 7 && tp[i] == '\\')) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5895 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5896 #ifdef FEAT_TERMRESPONSE |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5897 int number = argp[3] - '0'; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5898 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5899 // 0, 1 = block blink, 2 = block |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5900 // 3 = underline blink, 4 = underline |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5901 // 5 = vertical bar blink, 6 = vertical bar |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5902 number = number == 0 ? 1 : number; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5903 initial_cursor_shape = (number + 1) / 2; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5904 // The blink flag is actually inverted, compared to |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5905 // the value set with T_SH. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5906 initial_cursor_shape_blink = |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5907 (number & 1) ? FALSE : TRUE; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5908 rcs_status.tr_progress = STATUS_GOT; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5909 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5910 LOG_TR(("Received cursor shape response: %s", tp)); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5911 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5912 key_name[0] = (int)KS_EXTRA; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5913 key_name[1] = (int)KE_IGNORE; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5914 *slen = i + 1; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5915 #ifdef FEAT_EVAL |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5916 set_vim_var_string(VV_TERMSTYLERESP, tp, *slen); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5917 #endif |
34132
8f94a72dfbed
patch 9.1.0029: Cannot act on various terminal response codes
Christian Brabandt <cb@256bit.org>
parents:
34074
diff
changeset
|
5918 apply_autocmds(EVENT_TERMRESPONSEALL, |
8f94a72dfbed
patch 9.1.0029: Cannot act on various terminal response codes
Christian Brabandt <cb@256bit.org>
parents:
34074
diff
changeset
|
5919 (char_u *)"cursorshape", NULL, FALSE, curbuf); |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5920 break; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5921 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5922 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5923 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5924 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5925 if (i == len) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5926 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5927 // These codes arrive many together, each code can be |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5928 // truncated at any point. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5929 LOG_TR(("not enough characters for XT")); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5930 return FAIL; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5931 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5932 return OK; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5933 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5934 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5935 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5936 * Check if typebuf.tb_buf[] contains a terminal key code. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5937 * Check from typebuf.tb_buf[typebuf.tb_off] to typebuf.tb_buf[typebuf.tb_off |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5938 * + "max_offset"]. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5939 * Return 0 for no match, -1 for partial match, > 0 for full match. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5940 * Return KEYLEN_REMOVED when a key code was deleted. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5941 * With a match, the match is removed, the replacement code is inserted in |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5942 * typebuf.tb_buf[] and the number of characters in typebuf.tb_buf[] is |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5943 * returned. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5944 * When "buf" is not NULL, buf[bufsize] is used instead of typebuf.tb_buf[]. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5945 * "buflen" is then the length of the string in buf[] and is updated for |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5946 * inserts and deletes. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5947 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5948 int |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5949 check_termcode( |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5950 int max_offset, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5951 char_u *buf, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5952 int bufsize, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5953 int *buflen) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5954 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5955 char_u *tp; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5956 char_u *p; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5957 int slen = 0; // init for GCC |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5958 int modslen; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5959 int len; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5960 int retval = 0; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5961 int offset; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5962 char_u key_name[2]; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5963 int modifiers; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5964 char_u *modifiers_start = NULL; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5965 int key; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5966 int new_slen; // Length of what will replace the termcode |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5967 char_u string[MAX_KEY_CODE_LEN + 1]; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5968 int i, j; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5969 int idx = 0; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5970 int cpo_koffset; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5971 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5972 cpo_koffset = (vim_strchr(p_cpo, CPO_KOFFSET) != NULL); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5973 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5974 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5975 * Speed up the checks for terminal codes by gathering all first bytes |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5976 * used in termleader[]. Often this is just a single <Esc>. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5977 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5978 if (need_gather) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5979 gather_termleader(); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5980 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5981 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5982 * Check at several positions in typebuf.tb_buf[], to catch something like |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5983 * "x<Up>" that can be mapped. Stop at max_offset, because characters |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5984 * after that cannot be used for mapping, and with @r commands |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5985 * typebuf.tb_buf[] can become very long. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5986 * This is used often, KEEP IT FAST! |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5987 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5988 for (offset = 0; offset < max_offset; ++offset) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5989 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5990 if (buf == NULL) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5991 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5992 if (offset >= typebuf.tb_len) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5993 break; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5994 tp = typebuf.tb_buf + typebuf.tb_off + offset; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5995 len = typebuf.tb_len - offset; // length of the input |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5996 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5997 else |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5998 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
5999 if (offset >= *buflen) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6000 break; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6001 tp = buf + offset; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6002 len = *buflen - offset; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6003 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6004 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6005 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6006 * Don't check characters after K_SPECIAL, those are already |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6007 * translated terminal chars (avoid translating ~@^Hx). |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6008 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6009 if (*tp == K_SPECIAL) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6010 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6011 offset += 2; // there are always 2 extra characters |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6012 continue; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6013 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6014 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6015 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6016 * Skip this position if the character does not appear as the first |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6017 * character in term_strings. This speeds up a lot, since most |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6018 * termcodes start with the same character (ESC or CSI). |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6019 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6020 i = *tp; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6021 for (p = termleader; *p && *p != i; ++p) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6022 ; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6023 if (*p == NUL) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6024 continue; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6025 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6026 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6027 * Skip this position if p_ek is not set and tp[0] is an ESC and we |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6028 * are in Insert mode. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6029 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6030 if (*tp == ESC && !p_ek && (State & MODE_INSERT)) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6031 continue; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6032 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6033 tp[len] = NUL; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6034 key_name[0] = NUL; // no key name found yet |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6035 key_name[1] = NUL; // no key name found yet |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6036 modifiers = 0; // no modifiers yet |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6037 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6038 #ifdef FEAT_GUI |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6039 if (gui.in_use) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6040 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6041 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6042 * GUI special key codes are all of the form [CSI xx]. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6043 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6044 if (*tp == CSI) // Special key from GUI |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6045 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6046 if (len < 3) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6047 return -1; // Shouldn't happen |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6048 slen = 3; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6049 key_name[0] = tp[1]; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6050 key_name[1] = tp[2]; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6051 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6052 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6053 else |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6054 #endif // FEAT_GUI |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6055 #ifdef MSWIN |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6056 if (len >= 3 && tp[0] == CSI && tp[1] == KS_EXTRA |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6057 && (tp[2] == KE_MOUSEUP |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6058 || tp[2] == KE_MOUSEDOWN |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6059 || tp[2] == KE_MOUSELEFT |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6060 || tp[2] == KE_MOUSERIGHT)) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6061 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6062 // MS-Windows console sends mouse scroll events encoded: |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6063 // - CSI |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6064 // - KS_EXTRA |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6065 // - {KE_MOUSE[UP|DOWN|LEFT|RIGHT]} |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6066 slen = 3; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6067 key_name[0] = tp[1]; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6068 key_name[1] = tp[2]; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6069 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6070 else |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6071 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6072 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6073 int mouse_index_found = -1; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6074 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6075 for (idx = 0; idx < tc_len; ++idx) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6076 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6077 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6078 * Ignore the entry if we are not at the start of |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6079 * typebuf.tb_buf[] |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6080 * and there are not enough characters to make a match. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6081 * But only when the 'K' flag is in 'cpoptions'. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6082 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6083 slen = termcodes[idx].len; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6084 modifiers_start = NULL; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6085 if (cpo_koffset && offset && len < slen) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6086 continue; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6087 if (STRNCMP(termcodes[idx].code, tp, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6088 (size_t)(slen > len ? len : slen)) == 0) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6089 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6090 int looks_like_mouse_start = FALSE; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6091 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6092 if (len < slen) // got a partial sequence |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6093 return -1; // need to get more chars |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6094 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6095 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6096 * When found a keypad key, check if there is another key |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6097 * that matches and use that one. This makes <Home> to be |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6098 * found instead of <kHome> when they produce the same |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6099 * key code. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6100 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6101 if (termcodes[idx].name[0] == 'K' |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6102 && VIM_ISDIGIT(termcodes[idx].name[1])) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6103 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6104 for (j = idx + 1; j < tc_len; ++j) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6105 if (termcodes[j].len == slen && |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6106 STRNCMP(termcodes[idx].code, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6107 termcodes[j].code, slen) == 0) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6108 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6109 idx = j; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6110 break; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6111 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6112 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6113 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6114 if (slen == 2 && len > 2 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6115 && termcodes[idx].code[0] == ESC |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6116 && termcodes[idx].code[1] == '[') |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6117 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6118 // The mouse termcode "ESC [" is also the prefix of |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6119 // "ESC [ I" (focus gained) and other keys. Check some |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6120 // more bytes to find out. |
34074
1629cc65d78d
patch 9.1.0006: is*() and to*() function may be unsafe
Christian Brabandt <cb@256bit.org>
parents:
33888
diff
changeset
|
6121 if (!SAFE_isdigit(tp[2])) |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6122 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6123 // ESC [ without number following: Only use it when |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6124 // there is no other match. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6125 looks_like_mouse_start = TRUE; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6126 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6127 else if (termcodes[idx].name[0] == KS_DEC_MOUSE) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6128 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6129 char_u *nr = tp + 2; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6130 int count = 0; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6131 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6132 // If a digit is following it could be a key with |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6133 // modifier, e.g., ESC [ 1;2P. Can be confused |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6134 // with DEC_MOUSE, which requires four numbers |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6135 // following. If not then it can't be a DEC_MOUSE |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6136 // code. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6137 for (;;) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6138 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6139 ++count; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6140 (void)getdigits(&nr); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6141 if (nr >= tp + len) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6142 return -1; // partial sequence |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6143 if (*nr != ';') |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6144 break; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6145 ++nr; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6146 if (nr >= tp + len) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6147 return -1; // partial sequence |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6148 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6149 if (count < 4) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6150 continue; // no match |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6151 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6152 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6153 if (looks_like_mouse_start) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6154 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6155 // Only use it when there is no other match. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6156 if (mouse_index_found < 0) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6157 mouse_index_found = idx; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6158 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6159 else |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6160 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6161 key_name[0] = termcodes[idx].name[0]; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6162 key_name[1] = termcodes[idx].name[1]; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6163 break; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6164 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6165 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6166 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6167 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6168 * Check for code with modifier, like xterm uses: |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6169 * <Esc>[123;*X (modslen == slen - 3) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6170 * <Esc>[@;*X (matches <Esc>[X and <Esc>[1;9X ) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6171 * Also <Esc>O*X and <M-O>*X (modslen == slen - 2). |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6172 * When there is a modifier the * matches a number. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6173 * When there is no modifier the ;* or * is omitted. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6174 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6175 if (termcodes[idx].modlen > 0 && mouse_index_found < 0) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6176 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6177 modslen = termcodes[idx].modlen; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6178 if (cpo_koffset && offset && len < modslen) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6179 continue; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6180 if (STRNCMP(termcodes[idx].code, tp, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6181 (size_t)(modslen > len ? len : modslen)) == 0) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6182 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6183 int n; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6184 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6185 if (len <= modslen) // got a partial sequence |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6186 return -1; // need to get more chars |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6187 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6188 if (tp[modslen] == termcodes[idx].code[slen - 1]) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6189 // no modifiers |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6190 slen = modslen + 1; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6191 else if (tp[modslen] != ';' && modslen == slen - 3) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6192 // no match for "code;*X" with "code;" |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6193 continue; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6194 else if (termcodes[idx].code[modslen] == '@' |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6195 && (tp[modslen] != '1' |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6196 || tp[modslen + 1] != ';')) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6197 // no match for "<Esc>[@" with "<Esc>[1;" |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6198 continue; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6199 else |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6200 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6201 // Skip over the digits, the final char must |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6202 // follow. URXVT can use a negative value, thus |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6203 // also accept '-'. |
34074
1629cc65d78d
patch 9.1.0006: is*() and to*() function may be unsafe
Christian Brabandt <cb@256bit.org>
parents:
33888
diff
changeset
|
6204 for (j = slen - 2; j < len && (SAFE_isdigit(tp[j]) |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6205 || tp[j] == '-' || tp[j] == ';'); ++j) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6206 ; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6207 ++j; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6208 if (len < j) // got a partial sequence |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6209 return -1; // need to get more chars |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6210 if (tp[j - 1] != termcodes[idx].code[slen - 1]) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6211 continue; // no match |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6212 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6213 modifiers_start = tp + slen - 2; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6214 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6215 // Match! Convert modifier bits. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6216 n = atoi((char *)modifiers_start); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6217 modifiers |= decode_modifiers(n); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6218 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6219 slen = j; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6220 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6221 key_name[0] = termcodes[idx].name[0]; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6222 key_name[1] = termcodes[idx].name[1]; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6223 break; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6224 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6225 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6226 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6227 if (idx == tc_len && mouse_index_found >= 0) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6228 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6229 key_name[0] = termcodes[mouse_index_found].name[0]; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6230 key_name[1] = termcodes[mouse_index_found].name[1]; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6231 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6232 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6233 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6234 if (key_name[0] == NUL |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6235 // Mouse codes of DEC and pterm start with <ESC>[. When |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6236 // detecting the start of these mouse codes they might as well be |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6237 // another key code or terminal response. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6238 #ifdef FEAT_MOUSE_DEC |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6239 || key_name[0] == KS_DEC_MOUSE |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6240 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6241 #ifdef FEAT_MOUSE_PTERM |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6242 || key_name[0] == KS_PTERM_MOUSE |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6243 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6244 ) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6245 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6246 char_u *argp = tp[0] == ESC ? tp + 2 : tp + 1; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6247 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6248 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6249 * Check for responses from the terminal starting with {lead}: |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6250 * "<Esc>[" or CSI followed by [0-9>?]. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6251 * Also for function keys without a modifier: |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6252 * "<Esc>[" or CSI followed by [ABCDEFHPQRS]. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6253 * |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6254 * - Xterm version string: {lead}>{x};{vers};{y}c |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6255 * Also eat other possible responses to t_RV, rxvt returns |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6256 * "{lead}?1;2c". |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6257 * |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6258 * - Response to XTQMODKEYS: "{lead} > 4 ; Pv m". |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6259 * |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6260 * - Cursor position report: {lead}{row};{col}R |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6261 * The final byte must be 'R'. It is used for checking the |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6262 * ambiguous-width character state. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6263 * |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6264 * - window position reply: {lead}3;{x};{y}t |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6265 * |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6266 * - key with modifiers when modifyOtherKeys is enabled: |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6267 * {lead}27;{modifier};{key}~ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6268 * {lead}{key};{modifier}u |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6269 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6270 if (((tp[0] == ESC && len >= 3 && tp[1] == '[') |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6271 || (tp[0] == CSI && len >= 2)) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6272 && vim_strchr((char_u *)"0123456789>?ABCDEFHPQRS", |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6273 *argp) != NULL) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6274 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6275 int resp = handle_csi(tp, len, argp, offset, buf, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6276 bufsize, buflen, key_name, &slen); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6277 if (resp != 0) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6278 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6279 #ifdef DEBUG_TERMRESPONSE |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6280 if (resp == -1) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6281 LOG_TR(("Not enough characters for CSI sequence")); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6282 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6283 return resp; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6284 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6285 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6286 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6287 // Check for fore/background color response from the terminal, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6288 // starting} with <Esc>] or OSC |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6289 else if ((*T_RBG != NUL || *T_RFG != NUL) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6290 && ((tp[0] == ESC && len >= 2 && tp[1] == ']') |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6291 || tp[0] == OSC)) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6292 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6293 if (handle_osc(tp, argp, len, key_name, &slen) == FAIL) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6294 return -1; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6295 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6296 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6297 // Check for key code response from xterm, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6298 // starting with <Esc>P or DCS |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6299 // It would only be needed with this condition: |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6300 // (check_for_codes || rcs_status.tr_progress == STATUS_SENT) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6301 // Now this is always done so that DCS codes don't mess up things. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6302 else if ((tp[0] == ESC && len >= 2 && tp[1] == 'P') || tp[0] == DCS) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6303 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6304 if (handle_dcs(tp, argp, len, key_name, &slen) == FAIL) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6305 return -1; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6306 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6307 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6308 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6309 if (key_name[0] == NUL) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6310 continue; // No match at this position, try next one |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6311 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6312 // We only get here when we have a complete termcode match |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6313 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6314 #if defined(FEAT_GUI) || defined(MSWIN) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6315 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6316 * For scroll events from the GUI or MS-Windows console, fetch the |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6317 * pointer coordinates so that we know which window to scroll later. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6318 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6319 if (TRUE |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6320 # if defined(FEAT_GUI) && !defined(MSWIN) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6321 && gui.in_use |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6322 # endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6323 && key_name[0] == (int)KS_EXTRA |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6324 && (key_name[1] == (int)KE_X1MOUSE |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6325 || key_name[1] == (int)KE_X2MOUSE |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6326 || key_name[1] == (int)KE_MOUSEMOVE_XY |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6327 || key_name[1] == (int)KE_MOUSELEFT |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6328 || key_name[1] == (int)KE_MOUSERIGHT |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6329 || key_name[1] == (int)KE_MOUSEDOWN |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6330 || key_name[1] == (int)KE_MOUSEUP)) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6331 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6332 char_u bytes[6]; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6333 int num_bytes = get_bytes_from_buf(tp + slen, bytes, 4); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6334 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6335 if (num_bytes == -1) // not enough coordinates |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6336 return -1; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6337 mouse_col = 128 * (bytes[0] - ' ' - 1) + bytes[1] - ' ' - 1; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6338 mouse_row = 128 * (bytes[2] - ' ' - 1) + bytes[3] - ' ' - 1; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6339 slen += num_bytes; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6340 // equal to K_MOUSEMOVE |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6341 if (key_name[1] == (int)KE_MOUSEMOVE_XY) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6342 key_name[1] = (int)KE_MOUSEMOVE; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6343 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6344 else |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6345 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6346 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6347 * If it is a mouse click, get the coordinates. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6348 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6349 if (key_name[0] == KS_MOUSE |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6350 #ifdef FEAT_MOUSE_GPM |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6351 || key_name[0] == KS_GPM_MOUSE |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6352 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6353 #ifdef FEAT_MOUSE_JSB |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6354 || key_name[0] == KS_JSBTERM_MOUSE |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6355 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6356 #ifdef FEAT_MOUSE_NET |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6357 || key_name[0] == KS_NETTERM_MOUSE |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6358 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6359 #ifdef FEAT_MOUSE_DEC |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6360 || key_name[0] == KS_DEC_MOUSE |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6361 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6362 #ifdef FEAT_MOUSE_PTERM |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6363 || key_name[0] == KS_PTERM_MOUSE |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6364 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6365 #ifdef FEAT_MOUSE_URXVT |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6366 || key_name[0] == KS_URXVT_MOUSE |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6367 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6368 || key_name[0] == KS_SGR_MOUSE |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6369 || key_name[0] == KS_SGR_MOUSE_RELEASE) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6370 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6371 if (check_termcode_mouse(tp, &slen, key_name, modifiers_start, idx, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6372 &modifiers) == -1) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6373 return -1; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6374 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6375 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6376 #ifdef FEAT_GUI |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6377 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6378 * If using the GUI, then we get menu and scrollbar events. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6379 * |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6380 * A menu event is encoded as K_SPECIAL, KS_MENU, KE_FILLER followed by |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6381 * four bytes which are to be taken as a pointer to the vimmenu_T |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6382 * structure. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6383 * |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6384 * A tab line event is encoded as K_SPECIAL KS_TABLINE nr, where "nr" |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6385 * is one byte with the tab index. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6386 * |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6387 * A scrollbar event is K_SPECIAL, KS_VER_SCROLLBAR, KE_FILLER followed |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6388 * by one byte representing the scrollbar number, and then four bytes |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6389 * representing a long_u which is the new value of the scrollbar. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6390 * |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6391 * A horizontal scrollbar event is K_SPECIAL, KS_HOR_SCROLLBAR, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6392 * KE_FILLER followed by four bytes representing a long_u which is the |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6393 * new value of the scrollbar. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6394 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6395 # ifdef FEAT_MENU |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6396 else if (key_name[0] == (int)KS_MENU) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6397 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6398 long_u val; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6399 int num_bytes = get_long_from_buf(tp + slen, &val); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6400 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6401 if (num_bytes == -1) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6402 return -1; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6403 current_menu = (vimmenu_T *)val; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6404 slen += num_bytes; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6405 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6406 // The menu may have been deleted right after it was used, check |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6407 // for that. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6408 if (check_menu_pointer(root_menu, current_menu) == FAIL) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6409 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6410 key_name[0] = KS_EXTRA; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6411 key_name[1] = (int)KE_IGNORE; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6412 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6413 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6414 # endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6415 # ifdef FEAT_GUI_TABLINE |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6416 else if (key_name[0] == (int)KS_TABLINE) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6417 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6418 // Selecting tabline tab or using its menu. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6419 char_u bytes[6]; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6420 int num_bytes = get_bytes_from_buf(tp + slen, bytes, 1); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6421 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6422 if (num_bytes == -1) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6423 return -1; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6424 current_tab = (int)bytes[0]; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6425 if (current_tab == 255) // -1 in a byte gives 255 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6426 current_tab = -1; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6427 slen += num_bytes; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6428 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6429 else if (key_name[0] == (int)KS_TABMENU) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6430 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6431 // Selecting tabline tab or using its menu. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6432 char_u bytes[6]; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6433 int num_bytes = get_bytes_from_buf(tp + slen, bytes, 2); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6434 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6435 if (num_bytes == -1) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6436 return -1; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6437 current_tab = (int)bytes[0]; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6438 current_tabmenu = (int)bytes[1]; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6439 slen += num_bytes; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6440 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6441 # endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6442 # ifndef USE_ON_FLY_SCROLL |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6443 else if (key_name[0] == (int)KS_VER_SCROLLBAR) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6444 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6445 long_u val; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6446 char_u bytes[6]; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6447 int num_bytes; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6448 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6449 // Get the last scrollbar event in the queue of the same type |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6450 j = 0; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6451 for (i = 0; tp[j] == CSI && tp[j + 1] == KS_VER_SCROLLBAR |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6452 && tp[j + 2] != NUL; ++i) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6453 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6454 j += 3; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6455 num_bytes = get_bytes_from_buf(tp + j, bytes, 1); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6456 if (num_bytes == -1) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6457 break; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6458 if (i == 0) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6459 current_scrollbar = (int)bytes[0]; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6460 else if (current_scrollbar != (int)bytes[0]) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6461 break; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6462 j += num_bytes; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6463 num_bytes = get_long_from_buf(tp + j, &val); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6464 if (num_bytes == -1) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6465 break; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6466 scrollbar_value = val; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6467 j += num_bytes; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6468 slen = j; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6469 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6470 if (i == 0) // not enough characters to make one |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6471 return -1; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6472 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6473 else if (key_name[0] == (int)KS_HOR_SCROLLBAR) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6474 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6475 long_u val; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6476 int num_bytes; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6477 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6478 // Get the last horiz. scrollbar event in the queue |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6479 j = 0; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6480 for (i = 0; tp[j] == CSI && tp[j + 1] == KS_HOR_SCROLLBAR |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6481 && tp[j + 2] != NUL; ++i) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6482 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6483 j += 3; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6484 num_bytes = get_long_from_buf(tp + j, &val); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6485 if (num_bytes == -1) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6486 break; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6487 scrollbar_value = val; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6488 j += num_bytes; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6489 slen = j; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6490 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6491 if (i == 0) // not enough characters to make one |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6492 return -1; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6493 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6494 # endif // !USE_ON_FLY_SCROLL |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6495 #endif // FEAT_GUI |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6496 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6497 #if defined(UNIX) || defined(VMS) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6498 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6499 * Handle FocusIn/FocusOut event sequences reported by XTerm. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6500 * (CSI I/CSI O) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6501 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6502 if (key_name[0] == KS_EXTRA |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6503 # ifdef FEAT_GUI |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6504 && !gui.in_use |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6505 # endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6506 ) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6507 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6508 if (key_name[1] == KE_FOCUSGAINED) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6509 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6510 if (!focus_state) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6511 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6512 ui_focus_change(TRUE); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6513 did_cursorhold = TRUE; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6514 focus_state = TRUE; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6515 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6516 key_name[1] = (int)KE_IGNORE; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6517 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6518 else if (key_name[1] == KE_FOCUSLOST) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6519 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6520 if (focus_state) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6521 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6522 ui_focus_change(FALSE); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6523 did_cursorhold = TRUE; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6524 focus_state = FALSE; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6525 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6526 key_name[1] = (int)KE_IGNORE; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6527 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6528 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6529 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6530 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6531 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6532 * Change <xHome> to <Home>, <xUp> to <Up>, etc. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6533 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6534 key = handle_x_keys(TERMCAP2KEY(key_name[0], key_name[1])); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6535 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6536 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6537 * Add any modifier codes to our string. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6538 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6539 new_slen = modifiers2keycode(modifiers, &key, string); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6540 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6541 // Finally, add the special key code to our string |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6542 key_name[0] = KEY2TERMCAP0(key); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6543 key_name[1] = KEY2TERMCAP1(key); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6544 if (key_name[0] == KS_KEY) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6545 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6546 // from ":set <M-b>=xx" |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6547 if (has_mbyte) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6548 new_slen += (*mb_char2bytes)(key_name[1], string + new_slen); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6549 else |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6550 string[new_slen++] = key_name[1]; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6551 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6552 else if (new_slen == 0 && key_name[0] == KS_EXTRA |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6553 && key_name[1] == KE_IGNORE) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6554 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6555 // Do not put K_IGNORE into the buffer, do return KEYLEN_REMOVED |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6556 // to indicate what happened. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6557 retval = KEYLEN_REMOVED; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6558 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6559 else |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6560 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6561 string[new_slen++] = K_SPECIAL; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6562 string[new_slen++] = key_name[0]; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6563 string[new_slen++] = key_name[1]; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6564 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6565 if (put_string_in_typebuf(offset, slen, string, new_slen, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6566 buf, bufsize, buflen) == FAIL) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6567 return -1; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6568 return retval == 0 ? (len + new_slen - slen + offset) : retval; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6569 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6570 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6571 #ifdef FEAT_TERMRESPONSE |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6572 LOG_TR(("normal character")); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6573 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6574 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6575 return 0; // no match found |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6576 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6577 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6578 #if (defined(FEAT_TERMINAL) && defined(FEAT_TERMRESPONSE)) || defined(PROTO) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6579 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6580 * Get the text foreground color, if known. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6581 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6582 void |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6583 term_get_fg_color(char_u *r, char_u *g, char_u *b) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6584 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6585 if (rfg_status.tr_progress != STATUS_GOT) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6586 return; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6587 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6588 *r = fg_r; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6589 *g = fg_g; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6590 *b = fg_b; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6591 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6592 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6593 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6594 * Get the text background color, if known. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6595 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6596 void |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6597 term_get_bg_color(char_u *r, char_u *g, char_u *b) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6598 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6599 if (rbg_status.tr_progress != STATUS_GOT) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6600 return; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6601 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6602 *r = bg_r; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6603 *g = bg_g; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6604 *b = bg_b; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6605 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6606 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6607 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6608 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6609 * Replace any terminal code strings in from[] with the equivalent internal |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6610 * vim representation. This is used for the "from" and "to" part of a |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6611 * mapping, and the "to" part of a menu command. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6612 * Any strings like "<C-UP>" are also replaced, unless 'cpoptions' contains |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6613 * '<'. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6614 * K_SPECIAL by itself is replaced by K_SPECIAL KS_SPECIAL KE_FILLER. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6615 * |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6616 * The replacement is done in result[] and finally copied into allocated |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6617 * memory. If this all works well *bufp is set to the allocated memory and a |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6618 * pointer to it is returned. If something fails *bufp is set to NULL and from |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6619 * is returned. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6620 * |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6621 * CTRL-V characters are removed. When "flags" has REPTERM_FROM_PART, a |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6622 * trailing CTRL-V is included, otherwise it is removed (for ":map xx ^V", maps |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6623 * xx to nothing). When 'cpoptions' does not contain 'B', a backslash can be |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6624 * used instead of a CTRL-V. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6625 * |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6626 * Flags: |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6627 * REPTERM_FROM_PART see above |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6628 * REPTERM_DO_LT also translate <lt> |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6629 * REPTERM_SPECIAL always accept <key> notation |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6630 * REPTERM_NO_SIMPLIFY do not simplify <C-H> to 0x08 and set 8th bit for <A-x> |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6631 * |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6632 * "did_simplify" is set when some <C-H> or <A-x> code was simplified, unless |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6633 * it is NULL. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6634 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6635 char_u * |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6636 replace_termcodes( |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6637 char_u *from, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6638 char_u **bufp, |
32736
161ae1985d81
patch 9.0.1687: mapset() not properly handling script ID
Christian Brabandt <cb@256bit.org>
parents:
32670
diff
changeset
|
6639 scid_T sid_arg UNUSED, // script ID to use for <SID>, |
161ae1985d81
patch 9.0.1687: mapset() not properly handling script ID
Christian Brabandt <cb@256bit.org>
parents:
32670
diff
changeset
|
6640 // or 0 to use current_sctx |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6641 int flags, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6642 int *did_simplify) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6643 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6644 int i; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6645 int slen; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6646 int key; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6647 size_t dlen = 0; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6648 char_u *src; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6649 int do_backslash; // backslash is a special character |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6650 int do_special; // recognize <> key codes |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6651 int do_key_code; // recognize raw key codes |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6652 char_u *result; // buffer for resulting string |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6653 garray_T ga; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6654 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6655 do_backslash = (vim_strchr(p_cpo, CPO_BSLASH) == NULL); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6656 do_special = (vim_strchr(p_cpo, CPO_SPECI) == NULL) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6657 || (flags & REPTERM_SPECIAL); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6658 do_key_code = (vim_strchr(p_cpo, CPO_KEYCODE) == NULL); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6659 src = from; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6660 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6661 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6662 * Allocate space for the translation. Worst case a single character is |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6663 * replaced by 6 bytes (shifted special key), plus a NUL at the end. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6664 * In the rare case more might be needed ga_grow() must be called again. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6665 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6666 ga_init2(&ga, 1L, 100); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6667 if (ga_grow(&ga, (int)(STRLEN(src) * 6 + 1)) == FAIL) // out of memory |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6668 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6669 *bufp = NULL; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6670 return from; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6671 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6672 result = ga.ga_data; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6673 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6674 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6675 * Check for #n at start only: function key n |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6676 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6677 if ((flags & REPTERM_FROM_PART) && src[0] == '#' && VIM_ISDIGIT(src[1])) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6678 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6679 result[dlen++] = K_SPECIAL; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6680 result[dlen++] = 'k'; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6681 if (src[1] == '0') |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6682 result[dlen++] = ';'; // #0 is F10 is "k;" |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6683 else |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6684 result[dlen++] = src[1]; // #3 is F3 is "k3" |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6685 src += 2; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6686 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6687 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6688 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6689 * Copy each byte from *from to result[dlen] |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6690 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6691 while (*src != NUL) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6692 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6693 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6694 * If 'cpoptions' does not contain '<', check for special key codes, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6695 * like "<C-S-LeftMouse>" |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6696 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6697 if (do_special && ((flags & REPTERM_DO_LT) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6698 || STRNCMP(src, "<lt>", 4) != 0)) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6699 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6700 #ifdef FEAT_EVAL |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6701 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6702 * Change <SID>Func to K_SNR <script-nr> _Func. This name is used |
33223
def9fc5c92d1
patch 9.0.1886: Various Typos
Christian Brabandt <cb@256bit.org>
parents:
32736
diff
changeset
|
6703 * for script-local user functions. |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6704 * (room: 5 * 6 = 30 bytes; needed: 3 + <nr> + 1 <= 14) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6705 * Also change <SID>name.Func to K_SNR <import-script-nr> _Func. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6706 * Only if "name" is recognized as an import. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6707 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6708 if (STRNICMP(src, "<SID>", 5) == 0) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6709 { |
32736
161ae1985d81
patch 9.0.1687: mapset() not properly handling script ID
Christian Brabandt <cb@256bit.org>
parents:
32670
diff
changeset
|
6710 if (sid_arg < 0 || (sid_arg == 0 && current_sctx.sc_sid <= 0)) |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6711 emsg(_(e_using_sid_not_in_script_context)); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6712 else |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6713 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6714 char_u *dot; |
32736
161ae1985d81
patch 9.0.1687: mapset() not properly handling script ID
Christian Brabandt <cb@256bit.org>
parents:
32670
diff
changeset
|
6715 long sid = sid_arg != 0 ? sid_arg : current_sctx.sc_sid; |
32670
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6716 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6717 src += 5; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6718 if (in_vim9script() |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6719 && (dot = vim_strchr(src, '.')) != NULL) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6720 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6721 imported_T *imp = find_imported(src, dot - src, FALSE); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6722 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6723 if (imp != NULL) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6724 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6725 scriptitem_T *si = SCRIPT_ITEM(imp->imp_sid); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6726 size_t len; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6727 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6728 src = dot + 1; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6729 if (si->sn_autoload_prefix != NULL) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6730 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6731 // Turn "<SID>name.Func" |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6732 // into "scriptname#Func". |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6733 len = STRLEN(si->sn_autoload_prefix); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6734 if (ga_grow(&ga, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6735 (int)(STRLEN(src) * 6 + len + 1)) == FAIL) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6736 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6737 ga_clear(&ga); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6738 *bufp = NULL; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6739 return from; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6740 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6741 result = ga.ga_data; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6742 STRCPY(result + dlen, si->sn_autoload_prefix); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6743 dlen += len; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6744 continue; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6745 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6746 sid = imp->imp_sid; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6747 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6748 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6749 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6750 result[dlen++] = K_SPECIAL; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6751 result[dlen++] = (int)KS_EXTRA; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6752 result[dlen++] = (int)KE_SNR; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6753 sprintf((char *)result + dlen, "%ld", sid); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6754 dlen += STRLEN(result + dlen); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6755 result[dlen++] = '_'; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6756 continue; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6757 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6758 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6759 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6760 int fsk_flags = FSK_KEYCODE |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6761 | ((flags & REPTERM_NO_SIMPLIFY) ? 0 : FSK_SIMPLIFY) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6762 | ((flags & REPTERM_FROM_PART) ? FSK_FROM_PART : 0); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6763 slen = trans_special(&src, result + dlen, fsk_flags, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6764 TRUE, did_simplify); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6765 if (slen > 0) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6766 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6767 dlen += slen; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6768 continue; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6769 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6770 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6771 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6772 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6773 * If 'cpoptions' does not contain 'k', see if it's an actual key-code. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6774 * Note that this is also checked after replacing the <> form. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6775 * Single character codes are NOT replaced (e.g. ^H or DEL), because |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6776 * it could be a character in the file. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6777 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6778 if (do_key_code) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6779 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6780 i = find_term_bykeys(src); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6781 if (i >= 0) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6782 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6783 result[dlen++] = K_SPECIAL; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6784 result[dlen++] = termcodes[i].name[0]; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6785 result[dlen++] = termcodes[i].name[1]; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6786 src += termcodes[i].len; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6787 // If terminal code matched, continue after it. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6788 continue; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6789 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6790 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6791 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6792 #ifdef FEAT_EVAL |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6793 if (do_special) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6794 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6795 char_u *p, *s, len; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6796 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6797 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6798 * Replace <Leader> by the value of "mapleader". |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6799 * Replace <LocalLeader> by the value of "maplocalleader". |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6800 * If "mapleader" or "maplocalleader" isn't set use a backslash. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6801 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6802 if (STRNICMP(src, "<Leader>", 8) == 0) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6803 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6804 len = 8; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6805 p = get_var_value((char_u *)"g:mapleader"); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6806 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6807 else if (STRNICMP(src, "<LocalLeader>", 13) == 0) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6808 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6809 len = 13; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6810 p = get_var_value((char_u *)"g:maplocalleader"); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6811 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6812 else |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6813 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6814 len = 0; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6815 p = NULL; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6816 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6817 if (len != 0) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6818 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6819 // Allow up to 8 * 6 characters for "mapleader". |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6820 if (p == NULL || *p == NUL || STRLEN(p) > 8 * 6) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6821 s = (char_u *)"\\"; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6822 else |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6823 s = p; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6824 while (*s != NUL) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6825 result[dlen++] = *s++; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6826 src += len; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6827 continue; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6828 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6829 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6830 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6831 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6832 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6833 * Remove CTRL-V and ignore the next character. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6834 * For "from" side the CTRL-V at the end is included, for the "to" |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6835 * part it is removed. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6836 * If 'cpoptions' does not contain 'B', also accept a backslash. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6837 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6838 key = *src; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6839 if (key == Ctrl_V || (do_backslash && key == '\\')) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6840 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6841 ++src; // skip CTRL-V or backslash |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6842 if (*src == NUL) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6843 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6844 if (flags & REPTERM_FROM_PART) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6845 result[dlen++] = key; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6846 break; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6847 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6848 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6849 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6850 // skip multibyte char correctly |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6851 for (i = (*mb_ptr2len)(src); i > 0; --i) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6852 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6853 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6854 * If the character is K_SPECIAL, replace it with K_SPECIAL |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6855 * KS_SPECIAL KE_FILLER. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6856 * If compiled with the GUI replace CSI with K_CSI. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6857 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6858 if (*src == K_SPECIAL) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6859 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6860 result[dlen++] = K_SPECIAL; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6861 result[dlen++] = KS_SPECIAL; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6862 result[dlen++] = KE_FILLER; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6863 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6864 # ifdef FEAT_GUI |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6865 else if (*src == CSI) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6866 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6867 result[dlen++] = K_SPECIAL; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6868 result[dlen++] = KS_EXTRA; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6869 result[dlen++] = (int)KE_CSI; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6870 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6871 # endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6872 else |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6873 result[dlen++] = *src; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6874 ++src; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6875 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6876 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6877 result[dlen] = NUL; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6878 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6879 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6880 * Copy the new string to allocated memory. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6881 * If this fails, just return from. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6882 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6883 if ((*bufp = vim_strsave(result)) != NULL) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6884 from = *bufp; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6885 vim_free(result); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6886 return from; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6887 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6888 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6889 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6890 * Find a termcode with keys 'src' (must be NUL terminated). |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6891 * Return the index in termcodes[], or -1 if not found. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6892 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6893 static int |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6894 find_term_bykeys(char_u *src) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6895 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6896 int i; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6897 int slen = (int)STRLEN(src); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6898 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6899 for (i = 0; i < tc_len; ++i) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6900 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6901 if (slen == termcodes[i].len |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6902 && STRNCMP(termcodes[i].code, src, (size_t)slen) == 0) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6903 return i; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6904 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6905 return -1; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6906 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6907 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6908 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6909 * Gather the first characters in the terminal key codes into a string. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6910 * Used to speed up check_termcode(). |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6911 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6912 static void |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6913 gather_termleader(void) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6914 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6915 int i; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6916 int len = 0; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6917 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6918 #ifdef FEAT_GUI |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6919 if (gui.in_use) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6920 termleader[len++] = CSI; // the GUI codes are not in termcodes[] |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6921 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6922 #ifdef FEAT_TERMRESPONSE |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6923 if (check_for_codes || *T_CRS != NUL) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6924 termleader[len++] = DCS; // the termcode response starts with DCS |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6925 // in 8-bit mode |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6926 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6927 termleader[len] = NUL; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6928 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6929 for (i = 0; i < tc_len; ++i) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6930 if (vim_strchr(termleader, termcodes[i].code[0]) == NULL) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6931 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6932 termleader[len++] = termcodes[i].code[0]; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6933 termleader[len] = NUL; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6934 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6935 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6936 need_gather = FALSE; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6937 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6938 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6939 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6940 * Show all termcodes (for ":set termcap") |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6941 * This code looks a lot like showoptions(), but is different. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6942 * "flags" can have OPT_ONECOLUMN. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6943 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6944 void |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6945 show_termcodes(int flags) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6946 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6947 int col; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6948 int *items; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6949 int item_count; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6950 int run; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6951 int row, rows; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6952 int cols; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6953 int i; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6954 int len; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6955 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6956 #define INC3 27 // try to make three columns |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6957 #define INC2 40 // try to make two columns |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6958 #define GAP 2 // spaces between columns |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6959 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6960 if (tc_len == 0) // no terminal codes (must be GUI) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6961 return; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6962 items = ALLOC_MULT(int, tc_len); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6963 if (items == NULL) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6964 return; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6965 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6966 // Highlight title |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6967 msg_puts_title(_("\n--- Terminal keys ---")); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6968 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6969 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6970 * Do the loop three times: |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6971 * 1. display the short items (non-strings and short strings) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6972 * 2. display the medium items (medium length strings) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6973 * 3. display the long items (remaining strings) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6974 * When "flags" has OPT_ONECOLUMN do everything in 3. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6975 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6976 for (run = (flags & OPT_ONECOLUMN) ? 3 : 1; run <= 3 && !got_int; ++run) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6977 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6978 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6979 * collect the items in items[] |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6980 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6981 item_count = 0; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6982 for (i = 0; i < tc_len; i++) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6983 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6984 len = show_one_termcode(termcodes[i].name, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6985 termcodes[i].code, FALSE); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6986 if ((flags & OPT_ONECOLUMN) || |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6987 (len <= INC3 - GAP ? run == 1 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6988 : len <= INC2 - GAP ? run == 2 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6989 : run == 3)) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6990 items[item_count++] = i; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6991 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6992 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6993 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6994 * display the items |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6995 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6996 if (run <= 2) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6997 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6998 cols = (Columns + GAP) / (run == 1 ? INC3 : INC2); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
6999 if (cols == 0) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7000 cols = 1; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7001 rows = (item_count + cols - 1) / cols; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7002 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7003 else // run == 3 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7004 rows = item_count; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7005 for (row = 0; row < rows && !got_int; ++row) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7006 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7007 msg_putchar('\n'); // go to next line |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7008 if (got_int) // 'q' typed in more |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7009 break; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7010 col = 0; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7011 for (i = row; i < item_count; i += rows) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7012 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7013 msg_col = col; // make columns |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7014 show_one_termcode(termcodes[items[i]].name, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7015 termcodes[items[i]].code, TRUE); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7016 if (run == 2) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7017 col += INC2; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7018 else |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7019 col += INC3; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7020 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7021 out_flush(); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7022 ui_breakcheck(); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7023 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7024 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7025 vim_free(items); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7026 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7027 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7028 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7029 * Show one termcode entry. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7030 * Output goes into IObuff[] |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7031 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7032 int |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7033 show_one_termcode(char_u *name, char_u *code, int printit) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7034 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7035 char_u *p; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7036 int len; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7037 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7038 if (name[0] > '~') |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7039 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7040 IObuff[0] = ' '; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7041 IObuff[1] = ' '; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7042 IObuff[2] = ' '; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7043 IObuff[3] = ' '; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7044 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7045 else |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7046 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7047 IObuff[0] = 't'; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7048 IObuff[1] = '_'; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7049 IObuff[2] = name[0]; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7050 IObuff[3] = name[1]; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7051 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7052 IObuff[4] = ' '; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7053 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7054 p = get_special_key_name(TERMCAP2KEY(name[0], name[1]), 0); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7055 if (p[1] != 't') |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7056 STRCPY(IObuff + 5, p); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7057 else |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7058 IObuff[5] = NUL; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7059 len = (int)STRLEN(IObuff); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7060 do |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7061 IObuff[len++] = ' '; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7062 while (len < 17); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7063 IObuff[len] = NUL; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7064 if (code == NULL) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7065 len += 4; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7066 else |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7067 len += vim_strsize(code); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7068 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7069 if (printit) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7070 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7071 msg_puts((char *)IObuff); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7072 if (code == NULL) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7073 msg_puts("NULL"); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7074 else |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7075 msg_outtrans(code); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7076 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7077 return len; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7078 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7079 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7080 #if defined(FEAT_TERMRESPONSE) || defined(PROTO) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7081 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7082 * For Xterm >= 140 compiled with OPT_TCAP_QUERY: Obtain the actually used |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7083 * termcap codes from the terminal itself. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7084 * We get them one by one to avoid a very long response string. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7085 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7086 static int xt_index_in = 0; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7087 static int xt_index_out = 0; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7088 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7089 static void |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7090 req_codes_from_term(void) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7091 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7092 xt_index_out = 0; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7093 xt_index_in = 0; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7094 req_more_codes_from_term(); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7095 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7096 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7097 static void |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7098 req_more_codes_from_term(void) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7099 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7100 char buf[23]; // extra size to shut up LGTM |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7101 int old_idx = xt_index_out; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7102 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7103 // Don't do anything when going to exit. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7104 if (exiting) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7105 return; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7106 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7107 // Send up to 10 more requests out than we received. Avoid sending too |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7108 // many, there can be a buffer overflow somewhere. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7109 while (xt_index_out < xt_index_in + 10 && key_names[xt_index_out] != NULL) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7110 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7111 char *key_name = key_names[xt_index_out]; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7112 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7113 MAY_WANT_TO_LOG_THIS; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7114 LOG_TR(("Requesting XT %d: %s", xt_index_out, key_name)); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7115 sprintf(buf, "\033P+q%02x%02x\033\\", key_name[0], key_name[1]); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7116 out_str_nf((char_u *)buf); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7117 ++xt_index_out; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7118 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7119 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7120 // Send the codes out right away. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7121 if (xt_index_out != old_idx) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7122 out_flush(); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7123 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7124 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7125 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7126 * Decode key code response from xterm: '<Esc>P1+r<name>=<string><Esc>\'. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7127 * A "0" instead of the "1" indicates a code that isn't supported. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7128 * Both <name> and <string> are encoded in hex. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7129 * "code" points to the "0" or "1". |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7130 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7131 static void |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7132 got_code_from_term(char_u *code, int len) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7133 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7134 #define XT_LEN 100 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7135 char_u name[3]; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7136 char_u str[XT_LEN]; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7137 int i; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7138 int j = 0; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7139 int c; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7140 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7141 // A '1' means the code is supported, a '0' means it isn't. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7142 // When half the length is > XT_LEN we can't use it. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7143 // Our names are currently all 2 characters. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7144 if (code[0] == '1' && code[7] == '=' && len / 2 < XT_LEN) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7145 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7146 // Get the name from the response and find it in the table. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7147 name[0] = hexhex2nr(code + 3); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7148 name[1] = hexhex2nr(code + 5); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7149 name[2] = NUL; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7150 for (i = 0; key_names[i] != NULL; ++i) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7151 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7152 if (STRCMP(key_names[i], name) == 0) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7153 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7154 xt_index_in = i; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7155 break; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7156 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7157 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7158 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7159 LOG_TR(("Received XT %d: %s", xt_index_in, (char *)name)); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7160 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7161 if (key_names[i] != NULL) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7162 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7163 for (i = 8; (c = hexhex2nr(code + i)) >= 0; i += 2) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7164 str[j++] = c; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7165 str[j] = NUL; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7166 if (name[0] == 'C' && name[1] == 'o') |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7167 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7168 // Color count is not a key code. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7169 int val = atoi((char *)str); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7170 #if defined(FEAT_EVAL) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7171 if (val == t_colors) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7172 ch_log(NULL, "got_code_from_term(Co): no change (%d)", val); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7173 else |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7174 ch_log(NULL, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7175 "got_code_from_term(Co): changed from %d to %d", |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7176 t_colors, val); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7177 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7178 may_adjust_color_count(val); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7179 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7180 else |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7181 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7182 i = find_term_bykeys(str); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7183 if (i >= 0 && name[0] == termcodes[i].name[0] |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7184 && name[1] == termcodes[i].name[1]) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7185 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7186 // Existing entry with the same name and code - skip. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7187 #ifdef FEAT_EVAL |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7188 ch_log(NULL, "got_code_from_term(): Entry %c%c did not change", |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7189 name[0], name[1]); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7190 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7191 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7192 else |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7193 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7194 if (i >= 0) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7195 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7196 // Delete an existing entry using the same code. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7197 #ifdef FEAT_EVAL |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7198 ch_log(NULL, "got_code_from_term(): Deleting entry %c%c with matching keys %s", |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7199 termcodes[i].name[0], termcodes[i].name[1], str); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7200 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7201 del_termcode_idx(i); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7202 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7203 #ifdef FEAT_EVAL |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7204 else |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7205 ch_log(NULL, "got_code_from_term(): Adding entry %c%c with keys %s", |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7206 name[0], name[1], str); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7207 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7208 add_termcode(name, str, ATC_FROM_TERM); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7209 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7210 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7211 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7212 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7213 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7214 // May request more codes now that we received one. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7215 ++xt_index_in; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7216 req_more_codes_from_term(); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7217 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7218 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7219 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7220 * Check if there are any unanswered requests and deal with them. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7221 * This is called before starting an external program or getting direct |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7222 * keyboard input. We don't want responses to be send to that program or |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7223 * handled as typed text. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7224 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7225 static void |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7226 check_for_codes_from_term(void) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7227 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7228 int c; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7229 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7230 // If no codes requested or all are answered, no need to wait. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7231 if (xt_index_out == 0 || xt_index_out == xt_index_in) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7232 return; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7233 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7234 // Vgetc() will check for and handle any response. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7235 // Keep calling vpeekc() until we don't get any responses. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7236 ++no_mapping; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7237 ++allow_keys; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7238 for (;;) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7239 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7240 c = vpeekc(); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7241 if (c == NUL) // nothing available |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7242 break; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7243 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7244 // If a response is recognized it's replaced with K_IGNORE, must read |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7245 // it from the input stream. If there is no K_IGNORE we can't do |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7246 // anything, break here (there might be some responses further on, but |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7247 // we don't want to throw away any typed chars). |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7248 if (c != K_SPECIAL && c != K_IGNORE) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7249 break; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7250 c = vgetc(); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7251 if (c != K_IGNORE) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7252 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7253 vungetc(c); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7254 break; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7255 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7256 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7257 --no_mapping; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7258 --allow_keys; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7259 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7260 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7261 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7262 #if (defined(MSWIN) && (!defined(FEAT_GUI) || defined(VIMDLL))) || defined(PROTO) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7263 static char ksme_str[20]; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7264 static char ksmr_str[20]; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7265 static char ksmd_str[20]; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7266 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7267 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7268 * For Win32 console: update termcap codes for existing console attributes. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7269 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7270 void |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7271 update_tcap(int attr) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7272 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7273 sprintf(ksme_str, "\033|%dm", attr); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7274 sprintf(ksmd_str, "\033|%dm", attr | 0x08); // FOREGROUND_INTENSITY |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7275 sprintf(ksmr_str, "\033|%dm", ((attr & 0x0F) << 4) | ((attr & 0xF0) >> 4)); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7276 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7277 tcap_entry_T *p = find_builtin_term(DEFAULT_TERM); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7278 if (p == NULL) // did not find it |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7279 return; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7280 while (p->bt_string != NULL) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7281 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7282 if (p->bt_entry == (int)KS_ME) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7283 p->bt_string = &ksme_str[0]; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7284 else if (p->bt_entry == (int)KS_MR) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7285 p->bt_string = &ksmr_str[0]; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7286 else if (p->bt_entry == (int)KS_MD) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7287 p->bt_string = &ksmd_str[0]; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7288 ++p; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7289 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7290 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7291 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7292 # ifdef FEAT_TERMGUICOLORS |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7293 # define KSSIZE 20 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7294 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7295 typedef enum |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7296 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7297 CMODE_INDEXED = 0, // Use cmd.exe 4bit palette. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7298 CMODE_RGB, // Use 24bit RGB colors using VTP. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7299 CMODE_256COL, // Emulate xterm's 256-color palette using VTP. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7300 CMODE_LAST, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7301 } cmode_T; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7302 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7303 struct ks_tbl_S |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7304 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7305 int code; // value of KS_ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7306 char *vtp; // code in RGB mode |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7307 char *vtp2; // code in 256color mode |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7308 char buf[CMODE_LAST][KSSIZE]; // real buffer |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7309 }; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7310 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7311 static struct ks_tbl_S ks_tbl[] = |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7312 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7313 {(int)KS_ME, "\033|0m", "\033|0m", {""}}, // normal |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7314 {(int)KS_MR, "\033|7m", "\033|7m", {""}}, // reverse |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7315 {(int)KS_MD, "\033|1m", "\033|1m", {""}}, // bold |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7316 {(int)KS_SO, "\033|91m", "\033|91m", {""}}, // standout: bright red text |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7317 {(int)KS_SE, "\033|39m", "\033|39m", {""}}, // standout end: default color |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7318 {(int)KS_CZH, "\033|3m", "\033|3m", {""}}, // italic |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7319 {(int)KS_CZR, "\033|0m", "\033|0m", {""}}, // italic end |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7320 {(int)KS_US, "\033|4m", "\033|4m", {""}}, // underscore |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7321 {(int)KS_UE, "\033|24m", "\033|24m", {""}}, // underscore end |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7322 # ifdef TERMINFO |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7323 {(int)KS_CAB, "\033|%p1%db", "\033|%p14%dm", {""}}, // set background color |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7324 {(int)KS_CAF, "\033|%p1%df", "\033|%p13%dm", {""}}, // set foreground color |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7325 {(int)KS_CS, "\033|%p1%d;%p2%dR", "\033|%p1%d;%p2%dR", {""}}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7326 {(int)KS_CSV, "\033|%p1%d;%p2%dV", "\033|%p1%d;%p2%dV", {""}}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7327 # else |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7328 {(int)KS_CAB, "\033|%db", "\033|4%dm", {""}}, // set background color |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7329 {(int)KS_CAF, "\033|%df", "\033|3%dm", {""}}, // set foreground color |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7330 {(int)KS_CS, "\033|%d;%dR", "\033|%d;%dR", {""}}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7331 {(int)KS_CSV, "\033|%d;%dV", "\033|%d;%dV", {""}}, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7332 # endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7333 {(int)KS_CCO, "256", "256", {""}}, // colors |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7334 {(int)KS_NAME, NULL, NULL, {""}} // terminator |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7335 }; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7336 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7337 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7338 * Find the first entry for "code" in the builtin termcap for "name". |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7339 * Returns NULL when not found. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7340 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7341 static tcap_entry_T * |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7342 find_first_tcap( |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7343 char_u *name, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7344 int code) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7345 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7346 tcap_entry_T *p = find_builtin_term(name); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7347 if (p == NULL) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7348 return NULL; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7349 while (p->bt_string != NULL) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7350 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7351 if (p->bt_entry == code) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7352 return p; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7353 ++p; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7354 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7355 return NULL; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7356 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7357 # endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7358 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7359 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7360 * For Win32 console: replace the sequence immediately after termguicolors. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7361 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7362 void |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7363 swap_tcap(void) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7364 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7365 # ifdef FEAT_TERMGUICOLORS |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7366 static int init_done = FALSE; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7367 static cmode_T curr_mode; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7368 struct ks_tbl_S *ks; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7369 cmode_T mode; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7370 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7371 if (!init_done) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7372 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7373 for (ks = ks_tbl; ks->code != (int)KS_NAME; ks++) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7374 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7375 tcap_entry_T *bt = find_first_tcap(DEFAULT_TERM, ks->code); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7376 if (bt != NULL) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7377 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7378 // Preserve the original value. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7379 STRNCPY(ks->buf[CMODE_INDEXED], bt->bt_string, KSSIZE); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7380 STRNCPY(ks->buf[CMODE_RGB], ks->vtp, KSSIZE); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7381 STRNCPY(ks->buf[CMODE_256COL], ks->vtp2, KSSIZE); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7382 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7383 bt->bt_string = ks->buf[CMODE_INDEXED]; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7384 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7385 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7386 init_done = TRUE; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7387 curr_mode = CMODE_INDEXED; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7388 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7389 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7390 if (p_tgc) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7391 mode = CMODE_RGB; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7392 else if (t_colors >= 256) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7393 mode = CMODE_256COL; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7394 else |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7395 mode = CMODE_INDEXED; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7396 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7397 if (mode == curr_mode) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7398 return; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7399 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7400 for (ks = ks_tbl; ks->code != (int)KS_NAME; ks++) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7401 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7402 tcap_entry_T *bt = find_first_tcap(DEFAULT_TERM, ks->code); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7403 if (bt != NULL) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7404 bt->bt_string = ks->buf[mode]; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7405 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7406 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7407 curr_mode = mode; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7408 # endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7409 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7410 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7411 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7412 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7413 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7414 #if (defined(MSWIN) && (!defined(FEAT_GUI_MSWIN) || defined(VIMDLL))) || defined(FEAT_TERMINAL) \ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7415 || defined(PROTO) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7416 static int cube_value[] = { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7417 0x00, 0x5F, 0x87, 0xAF, 0xD7, 0xFF |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7418 }; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7419 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7420 static int grey_ramp[] = { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7421 0x08, 0x12, 0x1C, 0x26, 0x30, 0x3A, 0x44, 0x4E, 0x58, 0x62, 0x6C, 0x76, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7422 0x80, 0x8A, 0x94, 0x9E, 0xA8, 0xB2, 0xBC, 0xC6, 0xD0, 0xDA, 0xE4, 0xEE |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7423 }; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7424 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7425 static const char_u ansi_table[16][3] = { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7426 // R G B |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7427 { 0, 0, 0}, // black |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7428 {224, 0, 0}, // dark red |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7429 { 0, 224, 0}, // dark green |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7430 {224, 224, 0}, // dark yellow / brown |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7431 { 0, 0, 224}, // dark blue |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7432 {224, 0, 224}, // dark magenta |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7433 { 0, 224, 224}, // dark cyan |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7434 {224, 224, 224}, // light grey |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7435 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7436 {128, 128, 128}, // dark grey |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7437 {255, 64, 64}, // light red |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7438 { 64, 255, 64}, // light green |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7439 {255, 255, 64}, // yellow |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7440 { 64, 64, 255}, // light blue |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7441 {255, 64, 255}, // light magenta |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7442 { 64, 255, 255}, // light cyan |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7443 {255, 255, 255}, // white |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7444 }; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7445 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7446 #if defined(MSWIN) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7447 // Mapping between cterm indices < 16 and their counterpart in the ANSI palette. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7448 static const char_u cterm_ansi_idx[] = { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7449 0, 4, 2, 6, 1, 5, 3, 7, 8, 12, 10, 14, 9, 13, 11, 15 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7450 }; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7451 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7452 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7453 #define ANSI_INDEX_NONE 0 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7454 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7455 void |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7456 ansi_color2rgb(int nr, char_u *r, char_u *g, char_u *b, char_u *ansi_idx) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7457 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7458 if (nr < 16) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7459 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7460 *r = ansi_table[nr][0]; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7461 *g = ansi_table[nr][1]; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7462 *b = ansi_table[nr][2]; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7463 *ansi_idx = nr; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7464 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7465 else |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7466 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7467 *r = 0; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7468 *g = 0; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7469 *b = 0; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7470 *ansi_idx = ANSI_INDEX_NONE; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7471 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7472 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7473 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7474 void |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7475 cterm_color2rgb(int nr, char_u *r, char_u *g, char_u *b, char_u *ansi_idx) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7476 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7477 int idx; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7478 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7479 if (nr < 16) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7480 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7481 #if defined(MSWIN) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7482 idx = cterm_ansi_idx[nr]; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7483 #else |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7484 idx = nr; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7485 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7486 *r = ansi_table[idx][0]; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7487 *g = ansi_table[idx][1]; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7488 *b = ansi_table[idx][2]; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7489 *ansi_idx = idx + 1; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7490 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7491 else if (nr < 232) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7492 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7493 // 216 color cube |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7494 idx = nr - 16; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7495 *r = cube_value[idx / 36 % 6]; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7496 *g = cube_value[idx / 6 % 6]; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7497 *b = cube_value[idx % 6]; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7498 *ansi_idx = ANSI_INDEX_NONE; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7499 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7500 else if (nr < 256) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7501 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7502 // 24 grey scale ramp |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7503 idx = nr - 232; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7504 *r = grey_ramp[idx]; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7505 *g = grey_ramp[idx]; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7506 *b = grey_ramp[idx]; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7507 *ansi_idx = ANSI_INDEX_NONE; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7508 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7509 else |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7510 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7511 *r = 0; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7512 *g = 0; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7513 *b = 0; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7514 *ansi_idx = ANSI_INDEX_NONE; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7515 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7516 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7517 #endif |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7518 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7519 /* |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7520 * Replace K_BS by <BS> and K_DEL by <DEL>. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7521 * Include any modifiers into the key and drop them. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7522 * Returns "len" adjusted for replaced codes. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7523 */ |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7524 int |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7525 term_replace_keycodes(char_u *ta_buf, int ta_len, int len_arg) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7526 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7527 int len = len_arg; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7528 int i; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7529 int c; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7530 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7531 for (i = ta_len; i < ta_len + len; ++i) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7532 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7533 if (ta_buf[i] == CSI && len - i > 3 && ta_buf[i + 1] == KS_MODIFIER) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7534 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7535 int modifiers = ta_buf[i + 2]; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7536 int key = ta_buf[i + 3]; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7537 |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7538 // Try to use the modifier to modify the key. In any case drop the |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7539 // modifier. |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7540 mch_memmove(ta_buf + i + 1, ta_buf + i + 4, (size_t)(len - i - 3)); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7541 len -= 3; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7542 if (key < 0x80) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7543 key = merge_modifyOtherKeys(key, &modifiers); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7544 ta_buf[i] = key; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7545 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7546 else if (ta_buf[i] == CSI && len - i > 2) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7547 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7548 c = TERMCAP2KEY(ta_buf[i + 1], ta_buf[i + 2]); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7549 if (c == K_DEL || c == K_KDEL || c == K_BS) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7550 { |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7551 mch_memmove(ta_buf + i + 1, ta_buf + i + 3, |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7552 (size_t)(len - i - 2)); |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7553 if (c == K_DEL || c == K_KDEL) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7554 ta_buf[i] = DEL; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7555 else |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7556 ta_buf[i] = Ctrl_H; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7557 len -= 2; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7558 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7559 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7560 else if (ta_buf[i] == '\r') |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7561 ta_buf[i] = '\n'; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7562 if (has_mbyte) |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7563 i += (*mb_ptr2len_len)(ta_buf + i, ta_len + len - i) - 1; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7564 } |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7565 return len; |
695b50472e85
Fix line endings issue
Christian Brabandt <cb@256bit.org>
parents:
32669
diff
changeset
|
7566 } |