diff --git a/fedac/native/pieces/list.mjs b/fedac/native/pieces/list.mjs index fc6405c160..2e77940fc3 100644 --- a/fedac/native/pieces/list.mjs +++ b/fedac/native/pieces/list.mjs @@ -39,6 +39,7 @@ const CODES = [ // Populated in boot — pieces not in MAIN or TOOLS let UNSTABLE = []; +let LISP_PIECES = []; function boot({ system }) { var known = {}; @@ -47,12 +48,18 @@ function boot({ system }) { var skip = { prompt: 1, lisp: 1, cc: 1, "404": 1, error: 1 }; var names = (system && system.listPieces ? system.listPieces() : []); UNSTABLE = []; + LISP_PIECES = []; for (var i = 0; i < names.length; i++) { - if (!known[names[i]] && !skip[names[i]]) { - UNSTABLE.push({ name: names[i] }); + var n = names[i]; + // .lisp pieces go in their own section + if (n.endsWith && n.endsWith(".lisp")) { + LISP_PIECES.push({ name: n.replace(".lisp", ""), desc: "common lisp" }); + } else if (!known[n] && !skip[n]) { + UNSTABLE.push({ name: n }); } } UNSTABLE.sort(function(a, b) { return a.name < b.name ? -1 : 1; }); + LISP_PIECES.sort(function(a, b) { return a.name < b.name ? -1 : 1; }); } function act({ event: e, system }) { @@ -141,6 +148,13 @@ function paint({ wipe, ink, box, line, write, screen }) { section("commands", COMMANDS, [T.fgDim, T.fgDim + 20, T.fgDim], [T.fgDim + 30, T.fgDim + 30, T.fgDim + 40], true); section("$codes", CODES, T.warn, T.warn, true); + if (LISP_PIECES.length > 0) { + section("lisp (" + LISP_PIECES.length + ")", LISP_PIECES, + [180, 120, 220], + [200, 150, 240], + true); + } + if (UNSTABLE.length > 0) { section("unstable (" + UNSTABLE.length + ")", UNSTABLE, [T.fgMute, T.fgMute - 10, T.fgMute], diff --git a/fedac/native/src/js-bindings.c b/fedac/native/src/js-bindings.c index 02e34af104..f54bfbb30d 100644 --- a/fedac/native/src/js-bindings.c +++ b/fedac/native/src/js-bindings.c @@ -3663,7 +3663,7 @@ static JSValue js_exec_node(JSContext *ctx, JSValueConst this_val, int argc, JSV return JS_TRUE; } -// system.listPieces() — scan /pieces/*.mjs, return array of piece names +// system.listPieces() — scan /pieces/*.mjs and /pieces/*.lisp, return array of piece names static JSValue js_list_pieces(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) { (void)this_val; (void)argc; (void)argv; JSValue arr = JS_NewArray(ctx); @@ -3672,14 +3672,22 @@ static JSValue js_list_pieces(JSContext *ctx, JSValueConst this_val, int argc, J struct dirent *ent; uint32_t idx = 0; while ((ent = readdir(d)) != NULL) { + if (ent->d_name[0] == '.') continue; + // Check for .mjs char *dot = strstr(ent->d_name, ".mjs"); - if (dot && dot[4] == '\0' && ent->d_name[0] != '.') { + if (dot && dot[4] == '\0') { char name[64]; int len = (int)(dot - ent->d_name); if (len > 63) len = 63; memcpy(name, ent->d_name, len); name[len] = '\0'; JS_SetPropertyUint32(ctx, arr, idx++, JS_NewString(ctx, name)); + continue; + } + // Check for .lisp — include extension so list.mjs can distinguish + dot = strstr(ent->d_name, ".lisp"); + if (dot && dot[5] == '\0') { + JS_SetPropertyUint32(ctx, arr, idx++, JS_NewString(ctx, ent->d_name)); } } closedir(d);