From f4926c0c61c10a761a30e90921643518adc636de Mon Sep 17 00:00:00 2001 From: rswindell <> Date: Sun, 24 May 2020 07:36:55 +0000 Subject: [PATCH] ansi_getxy() - handle unexpected cursor-position responses and stuff into the keyboard buffer (at the end) corrrectly. Previously, only part of the unexpected response would be placed in the keyboard buffer. --- src/sbbs3/ansiterm.cpp | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/sbbs3/ansiterm.cpp b/src/sbbs3/ansiterm.cpp index 97fbc6d348..d28a675cd0 100644 --- a/src/sbbs3/ansiterm.cpp +++ b/src/sbbs3/ansiterm.cpp @@ -221,6 +221,7 @@ void sbbs_t::ansi_getlines() bool sbbs_t::ansi_getxy(int* x, int* y) { int rsp=0, ch; + char str[128]; *x=0; *y=0; @@ -229,8 +230,9 @@ bool sbbs_t::ansi_getxy(int* x, int* y) time_t start=time(NULL); sys_status&=~SS_ABORT; - while(online && !(sys_status&SS_ABORT)) { + while(online && !(sys_status&SS_ABORT) && rsp < sizeof(str)) { if((ch=incom(1000))!=NOINP) { + str[rsp] = ch; if(ch==ESC && rsp==0) { rsp++; start=time(NULL); @@ -259,11 +261,19 @@ bool sbbs_t::ansi_getxy(int* x, int* y) } else if(ch=='R' && rsp) break; - else - ungetkey(ch); + else { + str[rsp + 1] = 0; +#ifdef _DEBUG + char dbg[128]; + c_escape_str(str, dbg, sizeof(dbg), /* Ctrl-only? */true); + lprintf(LOG_DEBUG, "Unexpected ansi_getxy response: '%s'", dbg); +#endif + ungetstr(str, /* insert */false); + rsp = 0; + } } if(time(NULL)-start>TIMEOUT_ANSI_GETXY) { - lprintf(LOG_NOTICE,"Node %d !TIMEOUT in ansi_getxy", cfg.node_num); + lprintf(LOG_NOTICE, "!TIMEOUT in ansi_getxy"); return(false); } } -- GitLab