#477 api keywords moved to TIC module

This commit is contained in:
BADIM-PC\Vadim 2017-12-21 10:40:56 +03:00
parent 1280a1291a
commit 67d5ad4860
6 changed files with 23 additions and 11 deletions

View File

@ -281,10 +281,8 @@ static void parse(const char* start, u8* color, const tic_script_config* config)
if(!keyword) if(!keyword)
{ {
static const char* const Api[] = API_KEYWORDS; for(s32 i = 0; i < config->apiCount; i++)
if(len == strlen(config->api[i]) && memcmp(wordStart, config->api[i], len) == 0)
for(s32 i = 0; i < COUNT_OF(Api); i++)
if(len == strlen(Api[i]) && memcmp(wordStart, Api[i], len) == 0)
{ {
memset(color + (wordStart - start), getConfig()->theme.code.api, len); memset(color + (wordStart - start), getConfig()->theme.code.api, len);
break; break;

View File

@ -816,7 +816,7 @@ static bool initJavascript(tic_mem* tic, const char* code)
static void callJavascriptTick(tic_mem* tic) static void callJavascriptTick(tic_mem* tic)
{ {
tic_machine* machine = (tic_machine*)tic; tic_machine* machine = (tic_machine*)tic;
const char* TicFunc = ApiKeywords[0]; const char* TicFunc = ApiKeywords[0];
duk_context* duk = machine->js; duk_context* duk = machine->js;
@ -901,8 +901,12 @@ static const tic_script_config JsSyntaxConfig =
.blockStringStart = NULL, .blockStringStart = NULL,
.blockStringEnd = NULL, .blockStringEnd = NULL,
.singleComment = "//", .singleComment = "//",
.keywords = JsKeywords, .keywords = JsKeywords,
.keywordsCount = COUNT_OF(JsKeywords), .keywordsCount = COUNT_OF(JsKeywords),
.api = ApiKeywords,
.apiCount = COUNT_OF(ApiKeywords),
}; };
const tic_script_config* getJsScriptConfig() const tic_script_config* getJsScriptConfig()

View File

@ -1329,8 +1329,12 @@ static const tic_script_config LuaSyntaxConfig =
.singleComment = "--", .singleComment = "--",
.blockStringStart = "[[", .blockStringStart = "[[",
.blockStringEnd = "]]", .blockStringEnd = "]]",
.keywords = LuaKeywords, .keywords = LuaKeywords,
.keywordsCount = COUNT_OF(LuaKeywords), .keywordsCount = COUNT_OF(LuaKeywords),
.api = ApiKeywords,
.apiCount = COUNT_OF(ApiKeywords),
}; };
const tic_script_config* getLuaScriptConfig() const tic_script_config* getLuaScriptConfig()
@ -1364,8 +1368,12 @@ static const tic_script_config MoonSyntaxConfig =
.blockStringStart = NULL, .blockStringStart = NULL,
.blockStringEnd = NULL, .blockStringEnd = NULL,
.singleComment = "--", .singleComment = "--",
.keywords = MoonKeywords, .keywords = MoonKeywords,
.keywordsCount = COUNT_OF(MoonKeywords), .keywordsCount = COUNT_OF(MoonKeywords),
.api = ApiKeywords,
.apiCount = COUNT_OF(ApiKeywords),
}; };
const tic_script_config* getMoonScriptConfig() const tic_script_config* getMoonScriptConfig()

View File

@ -28,6 +28,11 @@
#define SFX_DEF_SPEED (1 << SFX_SPEED_BITS) #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 typedef struct
{ {
s32 time; /* clock time of next delta */ s32 time; /* clock time of next delta */

View File

@ -111,12 +111,6 @@
#define TIC_BANKS (1 << TIC_BANK_BITS) #define TIC_BANKS (1 << TIC_BANK_BITS)
#define SFX_NOTES {"C-", "C#", "D-", "D#", "E-", "F-", "F#", "G-", "G#", "A-", "A#", "B-"} #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 #define TIC_FONT_CHARS 128
enum enum

View File

@ -90,6 +90,9 @@ typedef struct
const char* const * keywords; const char* const * keywords;
s32 keywordsCount; s32 keywordsCount;
const char* const * api;
s32 apiCount;
} tic_script_config; } tic_script_config;
typedef struct typedef struct