forked from xolatile/xhartae
Reimplemented syntax highlighting...
This commit is contained in:
parent
e52cb513c9
commit
2123c3d2eb
@ -72,8 +72,8 @@ static void syntax_delete (void) {
|
|||||||
// } while (--syntax_count != -1);
|
// } while (--syntax_count != -1);
|
||||||
|
|
||||||
for (offset = 0; offset < syntax_count; ++offset) {
|
for (offset = 0; offset < syntax_count; ++offset) {
|
||||||
syntax_begin [syntax_count] = deallocate (syntax_begin [syntax_count]);
|
syntax_begin [offset] = deallocate (syntax_begin [offset]);
|
||||||
syntax_end [syntax_count] = deallocate (syntax_end [syntax_count]);
|
syntax_end [offset] = deallocate (syntax_end [offset]);
|
||||||
}
|
}
|
||||||
|
|
||||||
syntax_enrange = deallocate (syntax_enrange);
|
syntax_enrange = deallocate (syntax_enrange);
|
||||||
@ -132,13 +132,17 @@ static int syntax_select (char * string, int * length) {
|
|||||||
|
|
||||||
for (select = offset = 0; select != syntax_count; ++select) {
|
for (select = offset = 0; select != syntax_count; ++select) {
|
||||||
if (syntax_enrange [select] == FALSE) {
|
if (syntax_enrange [select] == FALSE) {
|
||||||
if (string_compare_limit (string, syntax_begin [select], string_length (syntax_begin [select])) != 0) {
|
if (string_compare_limit (string, syntax_begin [select], string_length (syntax_begin [select])) == TRUE) {
|
||||||
goto selected;
|
break; // We need to limit our string comparisson function.
|
||||||
|
} else {
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (subset = 0; subset != string_length (syntax_begin [select]); ++subset) {
|
for (subset = 0; subset != string_length (syntax_begin [select]); ++subset) {
|
||||||
if (string [offset] == syntax_begin [select] [subset]) {
|
if (string [offset] == syntax_begin [select] [subset]) {
|
||||||
goto selected;
|
goto selected; // We can't use 'break' here, because it will exit only one loop, not both of them.
|
||||||
|
} else {
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -152,7 +156,71 @@ static int syntax_select (char * string, int * length) {
|
|||||||
return (syntax_count);
|
return (syntax_count);
|
||||||
}
|
}
|
||||||
|
|
||||||
offset = 0; // TODO: Left of to fix this. Since I changed Xyntax, I need to adapt it.
|
for (offset = 1; string [offset - 1] != '\0'; ++offset) {
|
||||||
|
if (string [offset] == syntax_escape [select]) {
|
||||||
|
++offset;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (syntax_derange [select] == FALSE) {
|
||||||
|
if (string_compare_limit (& string [offset], syntax_end [select], string_length (syntax_end [select])) == TRUE) {
|
||||||
|
* length = offset + string_length (syntax_end [select]);
|
||||||
|
return (select);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
subset = 0;
|
||||||
|
if (string_compare (syntax_end [select], "") == TRUE) {
|
||||||
|
break;
|
||||||
|
} do {
|
||||||
|
if (string [offset] == syntax_end [select] [subset]) {
|
||||||
|
* length = offset;
|
||||||
|
goto finished;
|
||||||
|
}
|
||||||
|
} while (++subset != string_length (syntax_end [select]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
finished:
|
||||||
|
|
||||||
|
return (select);
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
static int syntax_select (char * string, int * length) {
|
||||||
|
int offset = 0;
|
||||||
|
int select = 0;
|
||||||
|
|
||||||
|
fatal_failure (syntax_active == FALSE, "syntax_select: Syntax is not active.");
|
||||||
|
fatal_failure (string == NULL, "syntax_select: String is null.");
|
||||||
|
fatal_failure (length == NULL, "syntax_select: Length is null.");
|
||||||
|
|
||||||
|
do {
|
||||||
|
if (syntax_enrange [select] == 0) {
|
||||||
|
if (string_compare (string, syntax_begin [select]) == TRUE) {
|
||||||
|
if (syntax_derange [select] == 0) {
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
if (character_compare_array (string [string_length (syntax_begin [select])], syntax_end [select]) != 0) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
int subset = 0;
|
||||||
|
do {
|
||||||
|
if (string [offset] == syntax_begin [select] [subset]) {
|
||||||
|
goto selected;
|
||||||
|
}
|
||||||
|
} while (++subset != (int) string_length (syntax_begin [select]));
|
||||||
|
}
|
||||||
|
} while (++select != syntax_count);
|
||||||
|
|
||||||
|
selected:
|
||||||
|
|
||||||
|
if (select == syntax_count) {
|
||||||
|
* length = 1;
|
||||||
|
|
||||||
|
return (syntax_count);
|
||||||
|
}
|
||||||
|
|
||||||
do {
|
do {
|
||||||
++offset;
|
++offset;
|
||||||
@ -163,28 +231,28 @@ static int syntax_select (char * string, int * length) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (syntax_derange [select] == 0) {
|
if (syntax_derange [select] == 0) {
|
||||||
if (string_compare_limit (& string [offset], syntax_end [select], string_length (syntax_end [select]))) {
|
if (string_compare (& string [offset], syntax_end [select]) == TRUE) {
|
||||||
* length = offset + string_length (syntax_end [select]);
|
* length = offset + string_length (syntax_end [select]);
|
||||||
return (select);
|
return (select);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
subset = 0;
|
int subset = 0;
|
||||||
if (string_compare (syntax_end [select], "") == 0) {
|
if (string_compare (syntax_end [select], "") != 0) {
|
||||||
break;
|
break;
|
||||||
} do {
|
} do {
|
||||||
if (string [offset] == syntax_end [select] [subset]) {
|
if (string [offset] == syntax_end [select] [subset]) {
|
||||||
* length = offset;
|
* length = offset;
|
||||||
return (select);
|
return (select);
|
||||||
}
|
}
|
||||||
} while (++subset != string_length (syntax_end [select]));
|
} while (++subset != (int) string_length (syntax_end [select]));
|
||||||
}
|
}
|
||||||
} while (string [offset - 1] != '\0');
|
} while (string [offset - 1] != '\0');
|
||||||
|
|
||||||
return (select);
|
return (select);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
static void syntax_highlight_c (void) {
|
static void syntax_highlight_c (void) {
|
||||||
char * separators = ".,:;<=>+-*/%!&~^?|()[]{}'\" \t\r\n";
|
char * separators = ".,:;<=>+*-/%!&~^?|()[]{}'\" \t\r\n";
|
||||||
|
|
||||||
char * keywords [] = {
|
char * keywords [] = {
|
||||||
"register", "volatile", "auto", "const", "static", "extern", "if", "else",
|
"register", "volatile", "auto", "const", "static", "extern", "if", "else",
|
||||||
|
Loading…
Reference in New Issue
Block a user