string block works

This commit is contained in:
BADIM-PC\Vadim 2017-12-20 21:57:29 +03:00
parent 0e35b78508
commit d77aa85d4e
1 changed files with 41 additions and 1 deletions

View File

@ -411,6 +411,7 @@ static void parse(const char* start, u8* color)
const char* ptr = start; const char* ptr = start;
const char* blockCommentStart = NULL; const char* blockCommentStart = NULL;
const char* blockStringStart = NULL;
static const char BlockCommentStart[] = "--[["; static const char BlockCommentStart[] = "--[[";
static const char BlockCommentEnd[] = "]]"; static const char BlockCommentEnd[] = "]]";
@ -427,6 +428,36 @@ static void parse(const char* start, u8* color)
memset(color + (blockCommentStart - start), getConfig()->theme.code.comment, ptr - blockCommentStart); memset(color + (blockCommentStart - start), getConfig()->theme.code.comment, ptr - blockCommentStart);
blockCommentStart = NULL; blockCommentStart = NULL;
} }
else if(blockStringStart)
{
const char* blockStart = blockStringStart+1;
while(true)
{
const char* pos = strchr(blockStart, *blockStringStart);
if(pos)
{
if(*(pos-1) == '\\' && *(pos-2) != '\\')
{
blockStart = pos + 1;
}
else
{
ptr = pos + 1;
break;
}
}
else
{
ptr = blockStringStart + strlen(blockStringStart);
break;
}
}
memset(color + (blockStringStart - start), getConfig()->theme.code.string, ptr - blockStringStart);
blockStringStart = NULL;
}
else else
{ {
s32 blockCommentStartSize = strlen(BlockCommentStart); s32 blockCommentStartSize = strlen(BlockCommentStart);
@ -437,10 +468,19 @@ static void parse(const char* start, u8* color)
continue; continue;
} }
else else
{
if(c == '"' || c == '\'')
{
blockStringStart = ptr;
ptr += 1;
continue;
}
else
{ {
// do other stuff // do other stuff
} }
} }
}
// static const char Comment = '-'; // static const char Comment = '-';
// const char* singleCommentStart = NULL; // const char* singleCommentStart = NULL;