summaryrefslogtreecommitdiff
path: root/src/terminal.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2019-10-10 21:14:03 +0200
committerBram Moolenaar <Bram@vim.org>2019-10-10 21:14:03 +0200
commit6a0299d8f4c7a64c64d60a6bb39cfe6eaf892247 (patch)
treef90be14b4122755ec33df17f1cfe86bee4ed600a /src/terminal.c
parent07282f01da06c158bab4787adc89ec15d7eeb202 (diff)
downloadvim-git-6a0299d8f4c7a64c64d60a6bb39cfe6eaf892247.tar.gz
patch 8.1.2134: modifier keys are not always recognizedv8.1.2134
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.
Diffstat (limited to 'src/terminal.c')
-rw-r--r--src/terminal.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/src/terminal.c b/src/terminal.c
index 42a80cd7d..a992b444d 100644
--- a/src/terminal.c
+++ b/src/terminal.c
@@ -1371,11 +1371,13 @@ term_convert_key(term_T *term, int c, char *buf)
break;
}
+ // add modifiers for the typed key
+ mod |= mod_mask;
+
/*
* Convert special keys to vterm keys:
* - Write keys to vterm: vterm_keyboard_key()
* - Write output to channel.
- * TODO: use mod_mask
*/
if (key != VTERM_KEY_NONE)
/* Special key, let vterm convert it. */
@@ -1902,15 +1904,21 @@ term_vgetc()
{
int c;
int save_State = State;
+ int modify_other_keys =
+ vterm_is_modify_other_keys(curbuf->b_term->tl_vterm);
State = TERMINAL;
got_int = FALSE;
#ifdef MSWIN
ctrl_break_was_pressed = FALSE;
#endif
+ if (modify_other_keys)
+ ++no_reduce_keys;
c = vgetc();
got_int = FALSE;
State = save_State;
+ if (modify_other_keys)
+ --no_reduce_keys;
return c;
}
@@ -2255,6 +2263,7 @@ term_win_entered()
terminal_loop(int blocking)
{
int c;
+ int raw_c;
int termwinkey = 0;
int ret;
#ifdef UNIX
@@ -2307,6 +2316,13 @@ terminal_loop(int blocking)
if (c == K_IGNORE)
continue;
+ // vgetc may not include CTRL in the key when modify_other_keys is set.
+ raw_c = c;
+ if ((mod_mask & MOD_MASK_CTRL)
+ && ((c >= '`' && c <= 0x7f)
+ || (c >= '@' && c <= '_')))
+ c &= 0x1f;
+
#ifdef UNIX
/*
* The shell or another program may change the tty settings. Getting
@@ -2417,7 +2433,7 @@ terminal_loop(int blocking)
c = wc;
}
# endif
- if (send_keys_to_term(curbuf->b_term, c, TRUE) != OK)
+ if (send_keys_to_term(curbuf->b_term, raw_c, TRUE) != OK)
{
if (c == K_MOUSEMOVE)
/* We are sure to come back here, don't reset the cursor color