summaryrefslogtreecommitdiff
path: root/src/libvterm
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/libvterm
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/libvterm')
-rw-r--r--src/libvterm/include/vterm.h1
-rw-r--r--src/libvterm/src/keyboard.c11
-rw-r--r--src/libvterm/src/state.c5
-rw-r--r--src/libvterm/src/vterm_internal.h1
4 files changed, 18 insertions, 0 deletions
diff --git a/src/libvterm/include/vterm.h b/src/libvterm/include/vterm.h
index 02ea91cd5..28d0a10f5 100644
--- a/src/libvterm/include/vterm.h
+++ b/src/libvterm/include/vterm.h
@@ -200,6 +200,7 @@ size_t vterm_output_get_buffer_remaining(const VTerm *vt);
size_t vterm_output_read(VTerm *vt, char *buffer, size_t len);
+int vterm_is_modify_other_keys(VTerm *vt);
void vterm_keyboard_unichar(VTerm *vt, uint32_t c, VTermModifier mod);
void vterm_keyboard_key(VTerm *vt, VTermKey key, VTermModifier mod);
diff --git a/src/libvterm/src/keyboard.c b/src/libvterm/src/keyboard.c
index 62338c638..95b962ed6 100644
--- a/src/libvterm/src/keyboard.c
+++ b/src/libvterm/src/keyboard.c
@@ -4,10 +4,21 @@
#include "utf8.h"
+int vterm_is_modify_other_keys(VTerm *vt)
+{
+ return vt->state->mode.modify_other_keys;
+}
+
+
void vterm_keyboard_unichar(VTerm *vt, uint32_t c, VTermModifier mod)
{
int needs_CSIu;
+ if (vt->state->mode.modify_other_keys && mod != 0) {
+ vterm_push_output_sprintf_ctrl(vt, C1_CSI, "27;%d;%d~", mod+1, c);
+ return;
+ }
+
// The shift modifier is never important for Unicode characters
// apart from Space
if(c != ' ')
diff --git a/src/libvterm/src/state.c b/src/libvterm/src/state.c
index 1f7ac02de..6b2583af9 100644
--- a/src/libvterm/src/state.c
+++ b/src/libvterm/src/state.c
@@ -1334,6 +1334,11 @@ static int on_csi(const char *leader, const long args[], int argcount, const cha
vterm_state_setpen(state, args, argcount);
break;
+ case LEADER('>', 0x6d): // xterm resource modifyOtherKeys
+ if (argcount == 2 && args[0] == 4)
+ state->mode.modify_other_keys = args[1] == 2;
+ break;
+
case 0x6e: // DSR - ECMA-48 8.3.35
case LEADER('?', 0x6e): // DECDSR
val = CSI_ARG_OR(args[0], 0);
diff --git a/src/libvterm/src/vterm_internal.h b/src/libvterm/src/vterm_internal.h
index 5b6198bdc..e2b8b159b 100644
--- a/src/libvterm/src/vterm_internal.h
+++ b/src/libvterm/src/vterm_internal.h
@@ -124,6 +124,7 @@ struct VTermState
unsigned int leftrightmargin:1;
unsigned int bracketpaste:1;
unsigned int report_focus:1;
+ unsigned int modify_other_keys:1;
} mode;
VTermEncodingInstance encoding[4], encoding_utf8;