summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2020-09-10 23:03:30 +0200
committerwm4 <wm4@nowhere>2020-09-10 23:03:30 +0200
commitf250c2940385a13bb4f4f408a0504d1f0be5ee48 (patch)
tree8e8e62ba272fe63adb158dc23b08190e3a78874f
parent92e7f75becb3af4b3ea6e676f38cc2c627600eed (diff)
downloadmpv-f250c2940385a13bb4f4f408a0504d1f0be5ee48.tar.bz2
mpv-f250c2940385a13bb4f4f408a0504d1f0be5ee48.tar.xz
terminal-unix: attempt to support more CTRL
Hysterically stupid inconsistent legacy garbage from the 70ies or maybe even 60ies. What the fuck. I fucking hate computers so much. Fixes: #8072
-rw-r--r--osdep/terminal-unix.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/osdep/terminal-unix.c b/osdep/terminal-unix.c
index a2959ba237..d225d37943 100644
--- a/osdep/terminal-unix.c
+++ b/osdep/terminal-unix.c
@@ -212,23 +212,31 @@ static bool getch2(struct input_ctx *input_ctx)
}
if (!match) { // normal or unknown key
+ int mods = 0;
if (buf.b[0] == '\033') {
skip_buf(&buf, 1);
- if (buf.len > 0 && mp_isalnum(buf.b[0])) { // meta+normal key
- mp_input_put_key(input_ctx, buf.b[0] | MP_KEY_MODIFIER_ALT);
- skip_buf(&buf, 1);
+ if (buf.len > 0 && buf.b[0] > 0 && buf.b[0] < 127) {
+ // meta+normal key
+ mods |= MP_KEY_MODIFIER_ALT;
} else if (buf.len == 1 && buf.b[0] == '\033') {
+ // Make 2x ESC -> ESC (lone ESC is ambiguous).
mp_input_put_key(input_ctx, MP_KEY_ESC);
skip_buf(&buf, 1);
+ continue;
} else {
// Throw it away. Typically, this will be a complete,
// unsupported sequence, and dropping this will skip it.
skip_buf(&buf, buf.len);
+ continue;
}
- } else {
- mp_input_put_key(input_ctx, buf.b[0]);
- skip_buf(&buf, 1);
}
+ unsigned char c = buf.b[0];
+ skip_buf(&buf, 1);
+ if (c < 32) {
+ c = c <= 25 ? (c + 'a' - 1) : (c - 25 + '2' - 1);
+ mods |= MP_KEY_MODIFIER_CTRL;
+ }
+ mp_input_put_key(input_ctx, c | mods);
continue;
}