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

console.attributes can now be set with an attribute string (Ctrl-A codes sans

the Ctrl-A escape character).
new console.color_list array property, currently "invisible" (non-enumerable),
contains a list of color attribute values configured in attr.cfg.
parent 31911a55
No related branches found
No related tags found
No related merge requests found
......@@ -146,6 +146,11 @@ static JSBool js_console_set(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
sbbs->lncntr=val;
break;
case CON_PROP_ATTR:
if(JSVAL_IS_STRING(*vp)) {
if((str=JS_ValueToString(cx, *vp))==NULL)
break;
val=attrstr(JS_GetStringBytes(str));
}
sbbs->attr(val);
break;
case CON_PROP_TOS:
......@@ -210,7 +215,7 @@ static struct JSPropertySpec js_console_properties[] = {
static char* con_prop_desc[] = {
"status bit field (see CON_* in sbbsdefs.js for bit definitions)"
,"current line counter (used for automatic screen pause)"
,"current display attributes"
,"current display attributes (set with number or string value)"
,"set to 1 if the terminal cursor is already at the top of the screen"
,"number of terminal rows"
,"automatically detected terminal settings (see USER_* in sbbsdefs.js for bit definitions)"
......@@ -1120,11 +1125,13 @@ static JSClass js_console_class = {
JSObject* js_CreateConsoleObject(JSContext* cx, JSObject* parent)
{
JSObject* obj;
JSObject* obj;
sbbs_t* sbbs;
obj = JS_DefineObject(cx, parent, "console", &js_console_class, NULL, JSPROP_ENUMERATE);
if((sbbs=(sbbs_t*)JS_GetContextPrivate(cx))==NULL)
return(NULL);
if(obj==NULL)
if((obj=JS_DefineObject(cx, parent, "console", &js_console_class, NULL, JSPROP_ENUMERATE))==NULL)
return(NULL);
if(!JS_DefineProperties(cx, obj, js_console_properties))
......@@ -1133,6 +1140,23 @@ JSObject* js_CreateConsoleObject(JSContext* cx, JSObject* parent)
if (!js_DefineMethods(cx, obj, js_console_functions))
return(NULL);
/* Create an array of pre-defined colors */
JSObject* color_list;
if((color_list=JS_NewArrayObject(cx,0,NULL))==NULL)
return(NULL);
for(uint i=0;i<sbbs->cfg.total_colors;i++) {
jsval val=INT_TO_JSVAL(sbbs->cfg.color[i]);
if(!JS_SetElement(cx, color_list, i, &val))
return(NULL);
}
if(!JS_DefineProperty(cx, obj, "color_list", OBJECT_TO_JSVAL(color_list)
,NULL, NULL, 0))
return(NULL);
#ifdef _DEBUG
js_DescribeObject(cx,obj,"Controls the user's Telnet/RLogin terminal");
js_CreateArrayOfStrings(cx, obj, "_property_desc_list", con_prop_desc, JSPROP_READONLY);
......
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