terminal-unix: fix ^Z identification

When using "stty susp ''" to disable sending the TSTP signal with ^Z,
mpv didn't recognize ^Z correctly in the terminal:

  [input] No key binding found for key 'Ctrl+2'.

Because ASCII 26 (^Z) and above were incorrectly considered ^<NUMBER>.

This commit moves the cutoff between letters/numbers from 25 to 26 so
that ^Z is now detected correctly as ^<LETTER>.

Additionally, it rephrases the ^<NUMBER> formula for clarity.
This commit is contained in:
Martin Tournoij 2021-07-13 14:34:32 +08:00 committed by Avi Halachmi (:avih)
parent f223edb616
commit 854404a639
1 changed files with 2 additions and 1 deletions

View File

@ -235,7 +235,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);