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

New sbbs_t method: cursor_xy(), works with both PETSCII and ANSI terminals.

JS console.gotoxy() and the GOTOXY @-code now work with PETSCII terminals
(homes the cursor then moves down and right the appropriate number of rows
and columns). Bummer I didn't think of this method sooner.
parent 4849dde9
No related branches found
No related tags found
No related merge requests found
...@@ -1042,7 +1042,7 @@ const char* sbbs_t::atcode(char* sp, char* str, size_t maxlen, long* pmode) ...@@ -1042,7 +1042,7 @@ const char* sbbs_t::atcode(char* sp, char* str, size_t maxlen, long* pmode)
tp=strchr(sp,','); tp=strchr(sp,',');
if(tp!=NULL) { if(tp!=NULL) {
tp++; tp++;
ansi_gotoxy(atoi(sp+7),atoi(tp)); cursor_xy(atoi(sp+7),atoi(tp));
} }
return(nulstr); return(nulstr);
} }
......
...@@ -912,6 +912,20 @@ void sbbs_t::cursor_left(int count) ...@@ -912,6 +912,20 @@ void sbbs_t::cursor_left(int count)
column=0; column=0;
} }
bool sbbs_t::cursor_xy(int x, int y)
{
long term = term_supports();
if(term&ANSI)
return ansi_gotoxy(x, y);
if(term&PETSCII) {
outcom(PETSCII_HOME);
cursor_down(y - 1);
cursor_right(x - 1);
return true;
}
return false;
}
void sbbs_t::cleartoeol(void) void sbbs_t::cleartoeol(void)
{ {
int i,j; int i,j;
......
...@@ -1623,7 +1623,7 @@ js_gotoxy(JSContext *cx, uintN argc, jsval *arglist) ...@@ -1623,7 +1623,7 @@ js_gotoxy(JSContext *cx, uintN argc, jsval *arglist)
} }
rc=JS_SUSPENDREQUEST(cx); rc=JS_SUSPENDREQUEST(cx);
sbbs->ansi_gotoxy(x,y); sbbs->cursor_xy(x,y);
JS_RESUMEREQUEST(cx, rc); JS_RESUMEREQUEST(cx, rc);
return(JS_TRUE); return(JS_TRUE);
} }
...@@ -2096,7 +2096,7 @@ static jsSyncMethodSpec js_console_functions[] = { ...@@ -2096,7 +2096,7 @@ static jsSyncMethodSpec js_console_functions[] = {
}, },
{"ansi_gotoxy", js_gotoxy, 1, JSTYPE_ALIAS }, {"ansi_gotoxy", js_gotoxy, 1, JSTYPE_ALIAS },
{"gotoxy", js_gotoxy, 1, JSTYPE_VOID, JSDOCSTR("[x,y] or [object { x,y }]") {"gotoxy", js_gotoxy, 1, JSTYPE_VOID, JSDOCSTR("[x,y] or [object { x,y }]")
,JSDOCSTR("move cursor to a specific screen coordinate (ANSI, 1-based values), " ,JSDOCSTR("move cursor to a specific screen coordinate (ANSI or PETSCII, 1-based values), "
"arguments can be separate x and y coordinates or an object with x and y properties " "arguments can be separate x and y coordinates or an object with x and y properties "
"(like that returned from <tt>console.getxy()</tt>)") "(like that returned from <tt>console.getxy()</tt>)")
,311 ,311
...@@ -2129,7 +2129,7 @@ static jsSyncMethodSpec js_console_functions[] = { ...@@ -2129,7 +2129,7 @@ static jsSyncMethodSpec js_console_functions[] = {
}, },
{"ansi_getxy", js_getxy, 0, JSTYPE_ALIAS }, {"ansi_getxy", js_getxy, 0, JSTYPE_ALIAS },
{"getxy", js_getxy, 0, JSTYPE_OBJECT, JSDOCSTR("") {"getxy", js_getxy, 0, JSTYPE_OBJECT, JSDOCSTR("")
,JSDOCSTR("query the current cursor position on the remote terminal " ,JSDOCSTR("query the current cursor position on the remote (ANSI) terminal "
"and returns the coordinates as an object (with x and y properties)") "and returns the coordinates as an object (with x and y properties)")
,311 ,311
}, },
......
...@@ -744,6 +744,7 @@ public: ...@@ -744,6 +744,7 @@ public:
void cursor_down(int count=1); void cursor_down(int count=1);
void cursor_left(int count=1); void cursor_left(int count=1);
void cursor_right(int count=1); void cursor_right(int count=1);
bool cursor_xy(int x, int y);
void carriage_return(int count=1); void carriage_return(int count=1);
void line_feed(int count=1); void line_feed(int count=1);
void newline(int count=1); void newline(int count=1);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment