From 42e4fdfc597be278685f08bdba6da781c4ebaac0 Mon Sep 17 00:00:00 2001 From: Boris Faure Date: Sat, 1 Mar 2014 15:29:32 +0100 Subject: [PATCH] improve debug for unhandled csi --- src/bin/termptyesc.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/src/bin/termptyesc.c b/src/bin/termptyesc.c index a472143d..1ea13981 100644 --- a/src/bin/termptyesc.c +++ b/src/bin/termptyesc.c @@ -337,8 +337,9 @@ static int _handle_esc_csi(Termpty *ty, const Eina_Unicode *c, Eina_Unicode *ce) { Eina_Unicode *cc; - int arg, i; + int arg, i, j; Eina_Unicode buf[4096], *b; + char *pos; cc = (Eina_Unicode *)c; b = buf; @@ -893,7 +894,7 @@ _handle_esc_csi(Termpty *ty, const Eina_Unicode *c, Eina_Unicode *ce) } } } - if (!handled) ERR("unhandled '%c'", *cc); + if (!handled) goto unhandled; } break; case 'r': @@ -991,11 +992,25 @@ _handle_esc_csi(Termpty *ty, const Eina_Unicode *c, Eina_Unicode *ce) } break; default: - ERR("unhandled CSI '%c' (0x%02x)", *cc, *cc); - break; + goto unhandled; } cc++; return cc - c; +unhandled: + pos = (char *)buf; + + for (j = 0; c + j <= cc && j < 100; j++) + { + if ((pos - (char*)buf) > 4096 - 15) break; + if ((c[j] < ' ') || (c[j] >= 0x7f)) + pos += sprintf(pos, "\033[35m%08x\033[0m", c[j]); + else + pos += sprintf(pos, "%c", c[j]); + } + *pos = '\0'; + ERR("unhandled CSI '%c': %s", *cc, (char*)buf); + cc++; + return cc - c; } static int