Commit 3e521d47df6158a75ffe4387968b5548e5d05006

antirez 2014-03-13T10:19:07

linenoisePrintKeyCodes(): show character if printable.

diff --git a/linenoise.c b/linenoise.c
index c9a91bd..55d0030 100644
--- a/linenoise.c
+++ b/linenoise.c
@@ -101,6 +101,7 @@
 #include <errno.h>
 #include <string.h>
 #include <stdlib.h>
+#include <ctype.h>
 #include <sys/types.h>
 #include <sys/ioctl.h>
 #include <unistd.h>
@@ -814,7 +815,8 @@ void linenoisePrintKeyCodes(void) {
         quit[sizeof(quit)-1] = c; /* Insert current char on the right. */
         if (memcmp(quit,"quit",sizeof(quit)) == 0) break;
 
-        printf("%02x (%d) (type quit to exit)\n", (int)c, (int)c);
+        printf("'%c' %02x (%d) (type quit to exit)\n",
+            isprint(c) ? c : '?', (int)c, (int)c);
         printf("\x1b[0G"); /* Go left edge manually, we are in raw mode. */
         fflush(stdout);
     }