#477 api keywords moved to TIC module
This commit is contained in:
		@@ -281,10 +281,8 @@ static void parse(const char* start, u8* color, const tic_script_config* config)
 | 
			
		||||
 | 
			
		||||
			if(!keyword)
 | 
			
		||||
			{
 | 
			
		||||
				static const char* const Api[] = API_KEYWORDS;
 | 
			
		||||
 | 
			
		||||
				for(s32 i = 0; i < COUNT_OF(Api); i++)
 | 
			
		||||
					if(len == strlen(Api[i]) && memcmp(wordStart, Api[i], len) == 0)
 | 
			
		||||
				for(s32 i = 0; i < config->apiCount; i++)
 | 
			
		||||
					if(len == strlen(config->api[i]) && memcmp(wordStart, config->api[i], len) == 0)
 | 
			
		||||
					{
 | 
			
		||||
						memset(color + (wordStart - start), getConfig()->theme.code.api, len);
 | 
			
		||||
						break;
 | 
			
		||||
 
 | 
			
		||||
@@ -816,7 +816,7 @@ static bool initJavascript(tic_mem* tic, const char* code)
 | 
			
		||||
static void callJavascriptTick(tic_mem* tic)
 | 
			
		||||
{
 | 
			
		||||
	tic_machine* machine = (tic_machine*)tic;
 | 
			
		||||
	
 | 
			
		||||
 | 
			
		||||
	const char* TicFunc = ApiKeywords[0];
 | 
			
		||||
 | 
			
		||||
	duk_context* duk = machine->js;
 | 
			
		||||
@@ -901,8 +901,12 @@ static const tic_script_config JsSyntaxConfig =
 | 
			
		||||
	.blockStringStart	= NULL,
 | 
			
		||||
	.blockStringEnd		= NULL,
 | 
			
		||||
	.singleComment 		= "//",
 | 
			
		||||
 | 
			
		||||
	.keywords 			= JsKeywords,
 | 
			
		||||
	.keywordsCount 		= COUNT_OF(JsKeywords),
 | 
			
		||||
 | 
			
		||||
	.api 				= ApiKeywords,
 | 
			
		||||
	.apiCount 			= COUNT_OF(ApiKeywords),
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
const tic_script_config* getJsScriptConfig()
 | 
			
		||||
 
 | 
			
		||||
@@ -1329,8 +1329,12 @@ static const tic_script_config LuaSyntaxConfig =
 | 
			
		||||
	.singleComment 		= "--",
 | 
			
		||||
	.blockStringStart	= "[[",
 | 
			
		||||
	.blockStringEnd		= "]]",
 | 
			
		||||
 | 
			
		||||
	.keywords 			= LuaKeywords,
 | 
			
		||||
	.keywordsCount 		= COUNT_OF(LuaKeywords),
 | 
			
		||||
	
 | 
			
		||||
	.api 				= ApiKeywords,
 | 
			
		||||
	.apiCount 			= COUNT_OF(ApiKeywords),
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
const tic_script_config* getLuaScriptConfig()
 | 
			
		||||
@@ -1364,8 +1368,12 @@ static const tic_script_config MoonSyntaxConfig =
 | 
			
		||||
	.blockStringStart	= NULL,
 | 
			
		||||
	.blockStringEnd		= NULL,
 | 
			
		||||
	.singleComment 		= "--",
 | 
			
		||||
 | 
			
		||||
	.keywords 			= MoonKeywords,
 | 
			
		||||
	.keywordsCount 		= COUNT_OF(MoonKeywords),
 | 
			
		||||
 | 
			
		||||
	.api 				= ApiKeywords,
 | 
			
		||||
	.apiCount 			= COUNT_OF(ApiKeywords),
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
const tic_script_config* getMoonScriptConfig()
 | 
			
		||||
 
 | 
			
		||||
@@ -28,6 +28,11 @@
 | 
			
		||||
 | 
			
		||||
#define SFX_DEF_SPEED (1 << SFX_SPEED_BITS)
 | 
			
		||||
 | 
			
		||||
#define API_KEYWORDS {"TIC", "scanline", "OVR", "print", "cls", "pix", "line", "rect", "rectb", \
 | 
			
		||||
	"spr", "btn", "btnp", "sfx", "map", "mget", "mset", "peek", "poke", "peek4", "poke4", \
 | 
			
		||||
	"memcpy", "memset", "trace", "pmem", "time", "exit", "font", "mouse", "circ", "circb", "tri", "textri", \
 | 
			
		||||
	"clip", "music", "sync", "reset"}
 | 
			
		||||
	
 | 
			
		||||
typedef struct
 | 
			
		||||
{
 | 
			
		||||
	s32 time;       /* clock time of next delta */
 | 
			
		||||
 
 | 
			
		||||
@@ -111,12 +111,6 @@
 | 
			
		||||
#define TIC_BANKS (1 << TIC_BANK_BITS)
 | 
			
		||||
 | 
			
		||||
#define SFX_NOTES {"C-", "C#", "D-", "D#", "E-", "F-", "F#", "G-", "G#", "A-", "A#", "B-"}
 | 
			
		||||
 | 
			
		||||
#define API_KEYWORDS {"TIC", "scanline", "OVR", "print", "cls", "pix", "line", "rect", "rectb", \
 | 
			
		||||
	"spr", "btn", "btnp", "sfx", "map", "mget", "mset", "peek", "poke", "peek4", "poke4", \
 | 
			
		||||
	"memcpy", "memset", "trace", "pmem", "time", "exit", "font", "mouse", "circ", "circb", "tri", "textri", \
 | 
			
		||||
	"clip", "music", "sync", "reset"}
 | 
			
		||||
 | 
			
		||||
#define TIC_FONT_CHARS 128
 | 
			
		||||
 | 
			
		||||
enum
 | 
			
		||||
 
 | 
			
		||||
@@ -90,6 +90,9 @@ typedef struct
 | 
			
		||||
 | 
			
		||||
	const char* const * keywords;
 | 
			
		||||
	s32 keywordsCount;
 | 
			
		||||
 | 
			
		||||
	const char* const * api;
 | 
			
		||||
	s32 apiCount;
 | 
			
		||||
} tic_script_config;
 | 
			
		||||
 | 
			
		||||
typedef struct
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user