Mercurial > vim
comparison src/terminal.c @ 18279:e8d1f3209dcd v8.1.2134
patch 8.1.2134: modifier keys are not always recognized
Commit: https://github.com/vim/vim/commit/6a0299d8f4c7a64c64d60a6bb39cfe6eaf892247
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Oct 10 21:14:03 2019 +0200
patch 8.1.2134: modifier keys are not always recognized
Problem: Modifier keys are not always recognized.
Solution: Handle key codes generated by xterm with modifyOtherKeys set.
Add this to libvterm so we can debug it.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 10 Oct 2019 21:15:04 +0200 |
parents | c8a53c0daeed |
children | 506bf60a30a0 |
comparison
equal
deleted
inserted
replaced
18278:1af5f27c8de2 | 18279:e8d1f3209dcd |
---|---|
1369 case K_PE: vterm_keyboard_end_paste(vterm); | 1369 case K_PE: vterm_keyboard_end_paste(vterm); |
1370 other = TRUE; | 1370 other = TRUE; |
1371 break; | 1371 break; |
1372 } | 1372 } |
1373 | 1373 |
1374 // add modifiers for the typed key | |
1375 mod |= mod_mask; | |
1376 | |
1374 /* | 1377 /* |
1375 * Convert special keys to vterm keys: | 1378 * Convert special keys to vterm keys: |
1376 * - Write keys to vterm: vterm_keyboard_key() | 1379 * - Write keys to vterm: vterm_keyboard_key() |
1377 * - Write output to channel. | 1380 * - Write output to channel. |
1378 * TODO: use mod_mask | |
1379 */ | 1381 */ |
1380 if (key != VTERM_KEY_NONE) | 1382 if (key != VTERM_KEY_NONE) |
1381 /* Special key, let vterm convert it. */ | 1383 /* Special key, let vterm convert it. */ |
1382 vterm_keyboard_key(vterm, key, mod); | 1384 vterm_keyboard_key(vterm, key, mod); |
1383 else if (!other) | 1385 else if (!other) |
1900 static int | 1902 static int |
1901 term_vgetc() | 1903 term_vgetc() |
1902 { | 1904 { |
1903 int c; | 1905 int c; |
1904 int save_State = State; | 1906 int save_State = State; |
1907 int modify_other_keys = | |
1908 vterm_is_modify_other_keys(curbuf->b_term->tl_vterm); | |
1905 | 1909 |
1906 State = TERMINAL; | 1910 State = TERMINAL; |
1907 got_int = FALSE; | 1911 got_int = FALSE; |
1908 #ifdef MSWIN | 1912 #ifdef MSWIN |
1909 ctrl_break_was_pressed = FALSE; | 1913 ctrl_break_was_pressed = FALSE; |
1910 #endif | 1914 #endif |
1915 if (modify_other_keys) | |
1916 ++no_reduce_keys; | |
1911 c = vgetc(); | 1917 c = vgetc(); |
1912 got_int = FALSE; | 1918 got_int = FALSE; |
1913 State = save_State; | 1919 State = save_State; |
1920 if (modify_other_keys) | |
1921 --no_reduce_keys; | |
1914 return c; | 1922 return c; |
1915 } | 1923 } |
1916 | 1924 |
1917 static int mouse_was_outside = FALSE; | 1925 static int mouse_was_outside = FALSE; |
1918 | 1926 |
2253 */ | 2261 */ |
2254 int | 2262 int |
2255 terminal_loop(int blocking) | 2263 terminal_loop(int blocking) |
2256 { | 2264 { |
2257 int c; | 2265 int c; |
2266 int raw_c; | |
2258 int termwinkey = 0; | 2267 int termwinkey = 0; |
2259 int ret; | 2268 int ret; |
2260 #ifdef UNIX | 2269 #ifdef UNIX |
2261 int tty_fd = curbuf->b_term->tl_job->jv_channel | 2270 int tty_fd = curbuf->b_term->tl_job->jv_channel |
2262 ->ch_part[get_tty_part(curbuf->b_term)].ch_fd; | 2271 ->ch_part[get_tty_part(curbuf->b_term)].ch_fd; |
2304 vungetc(c); | 2313 vungetc(c); |
2305 break; | 2314 break; |
2306 } | 2315 } |
2307 if (c == K_IGNORE) | 2316 if (c == K_IGNORE) |
2308 continue; | 2317 continue; |
2318 | |
2319 // vgetc may not include CTRL in the key when modify_other_keys is set. | |
2320 raw_c = c; | |
2321 if ((mod_mask & MOD_MASK_CTRL) | |
2322 && ((c >= '`' && c <= 0x7f) | |
2323 || (c >= '@' && c <= '_'))) | |
2324 c &= 0x1f; | |
2309 | 2325 |
2310 #ifdef UNIX | 2326 #ifdef UNIX |
2311 /* | 2327 /* |
2312 * The shell or another program may change the tty settings. Getting | 2328 * The shell or another program may change the tty settings. Getting |
2313 * them for every typed character is a bit of overhead, but it's needed | 2329 * them for every typed character is a bit of overhead, but it's needed |
2415 mb[1] = c; | 2431 mb[1] = c; |
2416 if (MultiByteToWideChar(GetACP(), 0, (char*)mb, 2, &wc, 1) > 0) | 2432 if (MultiByteToWideChar(GetACP(), 0, (char*)mb, 2, &wc, 1) > 0) |
2417 c = wc; | 2433 c = wc; |
2418 } | 2434 } |
2419 # endif | 2435 # endif |
2420 if (send_keys_to_term(curbuf->b_term, c, TRUE) != OK) | 2436 if (send_keys_to_term(curbuf->b_term, raw_c, TRUE) != OK) |
2421 { | 2437 { |
2422 if (c == K_MOUSEMOVE) | 2438 if (c == K_MOUSEMOVE) |
2423 /* We are sure to come back here, don't reset the cursor color | 2439 /* We are sure to come back here, don't reset the cursor color |
2424 * and shape to avoid flickering. */ | 2440 * and shape to avoid flickering. */ |
2425 restore_cursor = FALSE; | 2441 restore_cursor = FALSE; |