Skip to content
Snippets Groups Projects
Commit d9f006e1 authored by Rob Swindell's avatar Rob Swindell :speech_balloon:
Browse files

Merge remote-tracking branch 'origin/master' into new_config_format

parents 06ea266b e2098e8c
No related branches found
No related tags found
No related merge requests found
...@@ -208,6 +208,7 @@ bool sbbs_t::ansi_getxy(int* x, int* y) ...@@ -208,6 +208,7 @@ bool sbbs_t::ansi_getxy(int* x, int* y)
size_t rsp=0; size_t rsp=0;
int ch; int ch;
char str[128]; char str[128];
enum { state_escape, state_open, state_y, state_x } state = state_escape;
if(x != NULL) if(x != NULL)
*x=0; *x=0;
...@@ -218,39 +219,39 @@ bool sbbs_t::ansi_getxy(int* x, int* y) ...@@ -218,39 +219,39 @@ bool sbbs_t::ansi_getxy(int* x, int* y)
time_t start=time(NULL); time_t start=time(NULL);
sys_status&=~SS_ABORT; sys_status&=~SS_ABORT;
while(online && !(sys_status&SS_ABORT) && rsp < sizeof(str)) { while(online && !(sys_status&SS_ABORT) && rsp < sizeof(str) - 1) {
if((ch=incom(1000))!=NOINP) { if((ch=incom(1000))!=NOINP) {
str[rsp] = ch; str[rsp++] = ch;
if(ch==ESC && rsp==0) { if(ch==ESC && state == state_escape) {
rsp++; state = state_open;
start=time(NULL); start=time(NULL);
} }
else if(ch=='[' && rsp==1) { else if(ch=='[' && state == state_open) {
rsp++; state = state_y;
start=time(NULL); start=time(NULL);
} }
else if(IS_DIGIT(ch) && rsp==2) { else if(IS_DIGIT(ch) && state == state_y) {
if(y!=NULL) { if(y!=NULL) {
(*y)*=10; (*y)*=10;
(*y)+=(ch&0xf); (*y)+=(ch&0xf);
} }
start=time(NULL); start=time(NULL);
} }
else if(ch==';' && rsp>=2) { else if(ch==';' && state == state_y) {
rsp++; state = state_x;
start=time(NULL); start=time(NULL);
} }
else if(IS_DIGIT(ch) && rsp==3) { else if(IS_DIGIT(ch) && state == state_x) {
if(x!=NULL) { if(x!=NULL) {
(*x)*=10; (*x)*=10;
(*x)+=(ch&0xf); (*x)+=(ch&0xf);
} }
start=time(NULL); start=time(NULL);
} }
else if(ch=='R' && rsp) else if(ch=='R' && state == state_x)
break; break;
else { else {
str[rsp + 1] = 0; str[rsp] = '\0';
#ifdef _DEBUG #ifdef _DEBUG
char dbg[128]; char dbg[128];
c_escape_str(str, dbg, sizeof(dbg), /* Ctrl-only? */true); c_escape_str(str, dbg, sizeof(dbg), /* Ctrl-only? */true);
...@@ -258,6 +259,7 @@ bool sbbs_t::ansi_getxy(int* x, int* y) ...@@ -258,6 +259,7 @@ bool sbbs_t::ansi_getxy(int* x, int* y)
#endif #endif
ungetstr(str, /* insert */false); ungetstr(str, /* insert */false);
rsp = 0; rsp = 0;
state = state_escape;
} }
} }
if(time(NULL)-start>TIMEOUT_ANSI_GETXY) { if(time(NULL)-start>TIMEOUT_ANSI_GETXY) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment