Mercurial > vim
comparison src/terminal.c @ 31156:0ecb16d5f86f v9.0.0912
patch 9.0.0912: libvterm with modifyOtherKeys level 2 does not match xterm
Commit: https://github.com/vim/vim/commit/c896adbcdee8b2296433a61c1f009aae9f68a594
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Nov 19 19:02:40 2022 +0000
patch 9.0.0912: libvterm with modifyOtherKeys level 2 does not match xterm
Problem: libvterm with modifyOtherKeys level 2 does not match xterm.
Solution: Adjust key code escape sequences to be the same as what xterm
sends in modifyOtherKeys level 2 mode. Check the value of
no_reduce_keys before using it.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 19 Nov 2022 20:15:03 +0100 |
parents | 360f286b5869 |
children | dcde141f2d1e |
comparison
equal
deleted
inserted
replaced
31155:9173a376f251 | 31156:0ecb16d5f86f |
---|---|
2166 redraw_later(UPD_NOT_VALID); | 2166 redraw_later(UPD_NOT_VALID); |
2167 #endif | 2167 #endif |
2168 } | 2168 } |
2169 | 2169 |
2170 /* | 2170 /* |
2171 * When "modify_other_keys" is set then vgetc() should not reduce a key with | |
2172 * modifiers into a basic key. However, we may only find out after calling | |
2173 * vgetc(). Therefore vgetorpeek() will call check_no_reduce_keys() to update | |
2174 * "no_reduce_keys" before using it. | |
2175 */ | |
2176 typedef enum { | |
2177 NRKS_NONE, // initial value | |
2178 NRKS_CHECK, // modify_other_keys was off before calling vgetc() | |
2179 NRKS_SET, // no_reduce_keys was incremented in term_vgetc() or | |
2180 // check_no_reduce_keys(), must be decremented. | |
2181 } reduce_key_state_T; | |
2182 | |
2183 static reduce_key_state_T no_reduce_key_state = NRKS_NONE; | |
2184 | |
2185 void | |
2186 check_no_reduce_keys(void) | |
2187 { | |
2188 if (no_reduce_key_state != NRKS_CHECK | |
2189 || no_reduce_keys >= 1 | |
2190 || curbuf->b_term == NULL | |
2191 || curbuf->b_term->tl_vterm == NULL) | |
2192 return; | |
2193 | |
2194 if (vterm_is_modify_other_keys(curbuf->b_term->tl_vterm)) | |
2195 { | |
2196 // "modify_other_keys" was enabled while waiting. | |
2197 no_reduce_key_state = NRKS_SET; | |
2198 ++no_reduce_keys; | |
2199 } | |
2200 } | |
2201 | |
2202 /* | |
2171 * Get a key from the user with terminal mode mappings. | 2203 * Get a key from the user with terminal mode mappings. |
2172 * Note: while waiting a terminal may be closed and freed if the channel is | 2204 * Note: while waiting a terminal may be closed and freed if the channel is |
2173 * closed and ++close was used. This may even happen before we get here. | 2205 * closed and ++close was used. This may even happen before we get here. |
2174 */ | 2206 */ |
2175 static int | 2207 static int |
2176 term_vgetc() | 2208 term_vgetc() |
2177 { | 2209 { |
2178 int c; | 2210 int c; |
2179 int save_State = State; | 2211 int save_State = State; |
2180 int modify_other_keys = curbuf->b_term->tl_vterm == NULL ? FALSE | |
2181 : vterm_is_modify_other_keys(curbuf->b_term->tl_vterm); | |
2182 | 2212 |
2183 State = MODE_TERMINAL; | 2213 State = MODE_TERMINAL; |
2184 got_int = FALSE; | 2214 got_int = FALSE; |
2185 #ifdef MSWIN | 2215 #ifdef MSWIN |
2186 ctrl_break_was_pressed = FALSE; | 2216 ctrl_break_was_pressed = FALSE; |
2187 #endif | 2217 #endif |
2188 if (modify_other_keys) | 2218 |
2219 if (curbuf->b_term->tl_vterm != NULL | |
2220 && vterm_is_modify_other_keys(curbuf->b_term->tl_vterm)) | |
2221 { | |
2189 ++no_reduce_keys; | 2222 ++no_reduce_keys; |
2223 no_reduce_key_state = NRKS_SET; | |
2224 } | |
2225 else | |
2226 { | |
2227 no_reduce_key_state = NRKS_CHECK; | |
2228 } | |
2229 | |
2190 c = vgetc(); | 2230 c = vgetc(); |
2191 got_int = FALSE; | 2231 got_int = FALSE; |
2192 State = save_State; | 2232 State = save_State; |
2193 if (modify_other_keys) | 2233 |
2234 if (no_reduce_key_state == NRKS_SET) | |
2194 --no_reduce_keys; | 2235 --no_reduce_keys; |
2236 no_reduce_key_state = NRKS_NONE; | |
2237 | |
2195 return c; | 2238 return c; |
2196 } | 2239 } |
2197 | 2240 |
2198 static int mouse_was_outside = FALSE; | 2241 static int mouse_was_outside = FALSE; |
2199 | 2242 |