From 0a1bf64d0d9e0db397ea4482e84ba012fe654ee6 Mon Sep 17 00:00:00 2001 From: Mike Miller Date: Sat, 20 Oct 2018 22:01:25 -0400 Subject: [PATCH] adds support for Fennel text carts --- src/console.c | 22 +++++++++++++++++++--- src/studio.h | 1 + src/surf.c | 3 ++- 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/src/console.c b/src/console.c index c3d71df..5c19174 100644 --- a/src/console.c +++ b/src/console.c @@ -480,7 +480,7 @@ static void* getDemoCart(Console* console, ScriptLang script, s32* size) case MoonScript: strcpy(path, DefaultMoonTicPath); break; # endif -# if defined(TIC_BUILD_WITH_MOON) +# if defined(TIC_BUILD_WITH_FENNEL) case Fennel: strcpy(path, DefaultFennelTicPath); break; # endif @@ -690,12 +690,25 @@ static bool hasExt(const char* name, const char* ext) static bool hasProjectExt(const char* name) { - return hasExt(name, PROJECT_LUA_EXT) || hasExt(name, PROJECT_MOON_EXT) || hasExt(name, PROJECT_JS_EXT) || hasExt(name, PROJECT_WREN_EXT); + return hasExt(name, PROJECT_LUA_EXT) || + hasExt(name, PROJECT_MOON_EXT) || + hasExt(name, PROJECT_JS_EXT) || + hasExt(name, PROJECT_WREN_EXT) || + hasExt(name, PROJECT_FENNEL_EXT); } static const char* projectComment(const char* name) { - return hasExt(name, PROJECT_JS_EXT) || hasExt(name, PROJECT_WREN_EXT) ? "//" : "--"; + char* comment; + + if(hasExt(name, PROJECT_JS_EXT) || hasExt(name, PROJECT_WREN_EXT)) + comment = "//"; + else if(hasExt(name, PROJECT_FENNEL_EXT)) + comment = ";;"; + else + comment = "--"; + + return comment; } static void buf2str(const void* data, s32 size, char* ptr, bool flip) @@ -1069,6 +1082,9 @@ static void onConsoleLoadCommandConfirmed(Console* console, const char* param) if(!fsExistsFile(console->fs, name)) name = getName(param, PROJECT_WREN_EXT); + if(!fsExistsFile(console->fs, name)) + name = getName(param, PROJECT_FENNEL_EXT); + void* data = fsLoadFile(console->fs, name, &size); if(data) diff --git a/src/studio.h b/src/studio.h index da1ec50..9a06f05 100644 --- a/src/studio.h +++ b/src/studio.h @@ -60,6 +60,7 @@ #define PROJECT_JS_EXT ".js" #define PROJECT_WREN_EXT ".wren" #define PROJECT_SQUIRREL_EXT ".nut" +#define PROJECT_FENNEL_EXT ".fnl" typedef enum { diff --git a/src/surf.c b/src/surf.c index ab08f16..baa2797 100644 --- a/src/surf.c +++ b/src/surf.c @@ -396,6 +396,7 @@ static bool addMenuItem(const char* name, const char* info, s32 id, void* ptr, b || hasExt(name, PROJECT_MOON_EXT) || hasExt(name, PROJECT_JS_EXT) || hasExt(name, PROJECT_WREN_EXT) + || hasExt(name, PROJECT_FENNEL_EXT) #endif ) { @@ -533,7 +534,7 @@ static void loadCover(Surf* surf) if(cart) { - if(hasExt(item->name, PROJECT_LUA_EXT)) + if(hasExt(item->name, PROJECT_LUA_EXT) || hasExt(item->name, PROJECT_FENNEL_EXT)) surf->console->loadProject(surf->console, item->name, data, size, cart); else tic->api.load(cart, data, size, true);