diff options
Diffstat (limited to 'osdep/terminal-unix.c')
-rw-r--r-- | osdep/terminal-unix.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/osdep/terminal-unix.c b/osdep/terminal-unix.c index 86c3030cdd..adcf3a3540 100644 --- a/osdep/terminal-unix.c +++ b/osdep/terminal-unix.c @@ -221,6 +221,17 @@ static void process_input(struct input_ctx *input_ctx, bool timeout) if (!match) { // normal or unknown key int mods = 0; if (buf.b[0] == '\033') { + if (buf.len > 1 && buf.b[1] == '[') { + // unknown CSI sequence. wait till it completes + for (int i = 2; i < buf.len; i++) { + if (buf.b[i] >= 0x40 && buf.b[i] <= 0x7E) { + skip_buf(&buf, i+1); + continue; // complete - throw it away + } + } + goto read_more; // not yet complete + } + // non-CSI esc sequence skip_buf(&buf, 1); if (buf.len > 0 && buf.b[0] > 0 && buf.b[0] < 127) { // meta+normal key @@ -235,7 +246,8 @@ static void process_input(struct input_ctx *input_ctx, bool timeout) unsigned char c = buf.b[0]; skip_buf(&buf, 1); if (c < 32) { - c = c <= 25 ? (c + 'a' - 1) : (c - 25 + '2' - 1); + // 1..26 is ^A..^Z, and 27..31 is ^3..^7 + c = c <= 26 ? (c + 'a' - 1) : (c + '3' - 27); mods |= MP_KEY_MODIFIER_CTRL; } mp_input_put_key(input_ctx, c | mods); |