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

Add console.linefeed() method - for completionism

Seriously though, this doesn't always do the same thing as outputting a '\n'
(e.g. in PETSCII mode, it sends a "cursor down" (17) control character).
parent c2e4e621
No related branches found
No related tags found
1 merge request!455Update branch with changes from master
...@@ -2082,6 +2082,27 @@ js_creturn(JSContext *cx, uintN argc, jsval *arglist) ...@@ -2082,6 +2082,27 @@ js_creturn(JSContext *cx, uintN argc, jsval *arglist)
return(JS_TRUE); return(JS_TRUE);
} }
static JSBool
js_linefeed(JSContext *cx, uintN argc, jsval *arglist)
{
jsval *argv=JS_ARGV(cx, arglist);
sbbs_t* sbbs;
jsrefcount rc;
int32 val=1;
if((sbbs=(sbbs_t*)js_GetClassPrivate(cx, JS_THIS_OBJECT(cx, arglist), &js_console_class))==NULL)
return(JS_FALSE);
JS_SET_RVAL(cx, arglist, JSVAL_VOID);
if(argc) {
if(!JS_ValueToInt32(cx, argv[0], &val))
return JS_FALSE;
}
rc=JS_SUSPENDREQUEST(cx);
sbbs->line_feed(val);
JS_RESUMEREQUEST(cx, rc);
return(JS_TRUE);
}
static JSBool static JSBool
js_clearkeybuf(JSContext *cx, uintN argc, jsval *arglist) js_clearkeybuf(JSContext *cx, uintN argc, jsval *arglist)
...@@ -2683,9 +2704,13 @@ static jsSyncMethodSpec js_console_functions[] = { ...@@ -2683,9 +2704,13 @@ static jsSyncMethodSpec js_console_functions[] = {
,315 ,315
}, },
{"creturn", js_creturn, 0, JSTYPE_VOID, JSDOCSTR("[count=1]") {"creturn", js_creturn, 0, JSTYPE_VOID, JSDOCSTR("[count=1]")
,JSDOCSTR("Send a carriage return sequence") ,JSDOCSTR("Send carriage-return (or equivalent) character(s) - moving the cursor to the left-most screen column")
,31700 ,31700
}, },
{"linefeed", js_linefeed, 0, JSTYPE_VOID, JSDOCSTR("[count=1]")
,JSDOCSTR("Send line-feed (or equivalent) character(s) - moving the cursor down one or more screen rows")
,320
},
{"clearkeybuffer", js_clearkeybuf, 0, JSTYPE_VOID, JSDOCSTR("") {"clearkeybuffer", js_clearkeybuf, 0, JSTYPE_VOID, JSDOCSTR("")
,JSDOCSTR("Clear keyboard input buffer") ,JSDOCSTR("Clear keyboard input buffer")
,315 ,315
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment