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.
This commit is contained in:
Martin Lund 2022-09-29 20:18:32 +02:00
parent 0b61aaf451
commit 5f14924c96

View file

@ -259,8 +259,14 @@ static void output_hex(char c)
{ {
hex_chars[hex_char_index++] = c; hex_chars[hex_char_index++] = c;
printf("%c", c);
if (hex_char_index == 2) 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); unsigned char hex_value = char_to_nibble(hex_chars[0]) << 4 | (char_to_nibble(hex_chars[1]) & 0x0F);
hex_char_index = 0; hex_char_index = 0;