Add console module

This commit is contained in:
2025-12-03 20:05:06 +01:00
parent 4b4c3022eb
commit 19e034a982
7 changed files with 91 additions and 2 deletions

View File

@@ -93,13 +93,20 @@ JSValue jsKCPrintln(JSContext *ctx, JSValueConst jsThis, int argc, JSValueConst
return JS_UNDEFINED;
}
JSValue jsKCClearScreen(JSContext *ctx, JSValueConst jsThis, int argc, JSValueConst *argv) {
gST->ConOut->ClearScreen(gST->ConOut);
return JS_UNDEFINED;
}
void initKC(JSContext *ctx) {
JSValue global = JS_GetGlobalObject(ctx);
JSValue kc = JS_NewObject(ctx);
JS_SetPropertyStr(ctx, global, "kc", kc);
JS_SetPropertyStr(ctx, kc, "println", JS_NewCFunction(ctx, jsKCPrintln, "println", 1));
JS_SetPropertyStr(ctx, kc, "clearScreen", JS_NewCFunction(ctx, jsKCClearScreen, "clearScreen", 0));
JS_FreeValue(ctx, global);
}