diff options
author | Diogo Franco (Kovensky) <diogomfranco@gmail.com> | 2013-07-25 21:08:39 -0300 |
---|---|---|
committer | Diogo Franco (Kovensky) <diogomfranco@gmail.com> | 2013-07-25 21:10:06 -0300 |
commit | fb67770ed697ed4898f9019640bb389f2f6f588e (patch) | |
tree | 4e737255634d4674d86ab8bd7586cfac1b979c2d /osdep/getch2.c | |
parent | 590f011df1d5521a7eba435e2e6856767f036af3 (diff) | |
download | mpv-fb67770ed697ed4898f9019640bb389f2f6f588e.tar.bz2 mpv-fb67770ed697ed4898f9019640bb389f2f6f588e.tar.xz |
getch2: Support ESC keypresses again
Due to the termcap matching and the hardcoded fallbacks, the ESC keypress
has to be followed by another non-matching keypress (such as another ESC)
for it to be accepted. We drop the second ESC in case it was typed twice.
Diffstat (limited to 'osdep/getch2.c')
-rw-r--r-- | osdep/getch2.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/osdep/getch2.c b/osdep/getch2.c index 4ac955788c..4917a19827 100644 --- a/osdep/getch2.c +++ b/osdep/getch2.c @@ -386,7 +386,15 @@ bool getch2(struct input_ctx *input_ctx) if (utf8_len > 1) { state = STATE_UTF8; } else if (utf8_len == 1) { - mp_input_put_key(input_ctx, c); + switch (c) { + case 0x1b: /* ESC that's not part of escape sequence */ + mp_input_put_key(input_ctx, MP_KEY_ESC); + if (getch2_len > 1 && getch2_buf[1] == 0x1b) + walk_buf(1) /* eat the second ESC if it was typed twice */ + break; + default: + mp_input_put_key(input_ctx, c); + } walk_buf(1); } else walk_buf(getch2_pos); |