Skip to content
Snippets Groups Projects
Commit dc095e99 authored by rswindell's avatar rswindell
Browse files

Define and use new sbbs_t functions: ansi_gotoxy(), ansi_save() and

ansi_restore() in place of dumb macros that don't check the current terminal
support.
parent 8a928095
No related branches found
No related tags found
No related merge requests found
......@@ -159,3 +159,30 @@ bool sbbs_t::ansi_getxy(int* x, int* y)
return(true);
}
bool sbbs_t::ansi_gotoxy(int x, int y)
{
if(term_supports(ANSI)) {
rprintf("\x1b[%d;%dH",y,x);
return true;
}
return false;
}
bool sbbs_t::ansi_save(void)
{
if(term_supports(ANSI)) {
rputs("\x1b[s");
return true;
}
return false;
}
bool sbbs_t::ansi_restore(void)
{
if(term_supports(ANSI)) {
rputs("\x1b[u");
return true;
}
return false;
}
......@@ -8,7 +8,7 @@
* @format.tab-size 4 (Plain Text/Source Code File Header) *
* @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) *
* *
* Copyright 2007 Rob Swindell - http://www.synchro.net/copyright.html *
* Copyright 2009 Rob Swindell - http://www.synchro.net/copyright.html *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License *
......@@ -1140,7 +1140,7 @@ js_pushxy(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
return(JS_FALSE);
rc=JS_SUSPENDREQUEST(cx);
sbbs->ANSI_SAVE();
sbbs->ansi_save();
JS_RESUMEREQUEST(cx, rc);
return(JS_TRUE);
}
......@@ -1155,7 +1155,7 @@ js_popxy(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
return(JS_FALSE);
rc=JS_SUSPENDREQUEST(cx);
sbbs->ANSI_RESTORE();
sbbs->ansi_restore();
JS_RESUMEREQUEST(cx, rc);
return(JS_TRUE);
}
......@@ -1182,7 +1182,7 @@ js_gotoxy(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
}
rc=JS_SUSPENDREQUEST(cx);
sbbs->GOTOXY(x,y);
sbbs->ansi_gotoxy(x,y);
JS_RESUMEREQUEST(cx, rc);
return(JS_TRUE);
}
......
......@@ -8,7 +8,7 @@
* @format.tab-size 4 (Plain Text/Source Code File Header) *
* @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) *
* *
* Copyright 2008 Rob Swindell - http://www.synchro.net/copyright.html *
* Copyright 2009 Rob Swindell - http://www.synchro.net/copyright.html *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License *
......@@ -379,7 +379,10 @@ public:
/* ansi_term.cpp */
const char * ansi(int atr); /* Returns ansi escape sequence for atr */
bool ansi_gotoxy(int x, int y);
bool ansi_getxy(int* x, int* y);
bool ansi_save(void);
bool ansi_restore(void);
void ansi_getlines(void);
/* Command Shell Methods */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment