From 5f14924c964c731ba1e24bbb479b88c3d6cce747 Mon Sep 17 00:00:00 2001 From: Martin Lund Date: Thu, 29 Sep 2022 20:18:32 +0200 Subject: [PATCH] Improve input mechanism in hex mode Print the 2 character hex code that you input in hex mode but then delete it before sending. This way it is easier to keep track of what you are inputting. It basically mimics the ctrl-shift-u input mechanism that is used to input unicode. --- src/tty.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/tty.c b/src/tty.c index d5fb7af..0fd2579 100644 --- a/src/tty.c +++ b/src/tty.c @@ -259,8 +259,14 @@ static void output_hex(char c) { hex_chars[hex_char_index++] = c; + printf("%c", c); + if (hex_char_index == 2) { + usleep(100*1000); + printf("\b \b"); + printf("\b \b"); + unsigned char hex_value = char_to_nibble(hex_chars[0]) << 4 | (char_to_nibble(hex_chars[1]) & 0x0F); hex_char_index = 0;