Code editor lexer configuration files working.

This commit is contained in:
Scott Duensing 2023-01-28 19:48:24 -06:00
parent f274d56d0a
commit 1c287a912e
4 changed files with 81 additions and 35 deletions

View file

@ -82,11 +82,15 @@ EVENT void editorEditorNotify(GtkWidget *sciWidget, gint ctrlID, struct SCNotifi
static void loadEditorConfig(char *lexer, EditorDataT *self) {
char *config = NULL;
FILE *in = NULL;
char *line = NULL;
size_t len = 0;
char *c = NULL;
char *config = NULL;
FILE *in = NULL;
char *line = NULL;
size_t len = 0;
char *c = NULL;
char *type = NULL;
char *name = NULL;
unsigned int number;
unsigned int integer;
config = utilCreateString("%s%cjoeydev%ceditor-%s.conf", g_get_user_config_dir(), UTIL_PATH_CHAR, UTIL_PATH_CHAR, lexer);
if (!utilFileExists(config)) {
@ -100,7 +104,7 @@ static void loadEditorConfig(char *lexer, EditorDataT *self) {
if (in) {
// Load config.
utilEnsureBufferSize(&line, &len, 1024); // Not technically needed, but fixes a pointer warning from memmaker.
utilEnsureBufferSize((unsigned char **)&line, (int *)&len, 4096); // Not technically needed, but fixes a pointer warning from memmaker.
while (getline(&line, &len, in) != -1) {
if (strlen(line) > 0) line[strlen(line) - 1] = 0;
c = utilGetToken(line, " ", "\"", "\"");
@ -108,17 +112,59 @@ static void loadEditorConfig(char *lexer, EditorDataT *self) {
// Is this a 'style' line?
if (strcasecmp(c, "style") == 0) {
// style number "tags" "description" ... (style keywords)
c = utilGetToken(NULL, " ", "\"", "\"");
number = strtol(c, NULL, 10);
c = utilGetToken(NULL, " ", "\"", "\"");
c = utilGetToken(NULL, " ", "\"", "\"");
c = utilGetToken(NULL, " ", "\"", "\"");
do {
if (strcmp(c, "fore") == 0) {
c = utilGetToken(NULL, " ", "\"", "\"");
integer = strtol(c, NULL, 16);
SSM(SCI_STYLESETFORE, number, integer);
}
if (strcmp(c, "back") == 0) {
c = utilGetToken(NULL, " ", "\"", "\"");
integer = strtol(c, NULL, 16);
SSM(SCI_STYLESETBACK, number, integer);
}
if (strcmp(c, "bold") == 0) {
SSM(SCI_STYLESETBOLD, number, 1);
}
if (strcmp(c, "italic") == 0) {
SSM(SCI_STYLESETITALIC, number, 1);
}
c = utilGetToken(NULL, " ", "\"", "\"");
} while (c != NULL);
continue;
}
// Is this a 'property' line?
if (strcasecmp(c, "property") == 0) {
// property type name "description" value
c = utilGetToken(NULL, " ", "\"", "\"");
type = strdup(c);
c = utilGetToken(NULL, " ", "\"", "\"");
name = strdup(c);
c = utilGetToken(NULL, " ", "\"", "\"");
c = utilGetToken(NULL, " ", "\"", "\"");
utilDequote(c);
SSM(SCI_SETPROPERTY, (sptr_t)name, (sptr_t)c);
DEL(name);
DEL(type);
continue;
}
// Is this a 'keywords' line?
if (strcasecmp(c, "keywords") == 0) {
// keywords number "description" wordlist
c = utilGetToken(NULL, " ", "\"", "\"");
number = strtol(c, NULL, 10);
c = utilGetToken(NULL, " ", "\"", "\"");
c = utilGetToken(NULL, "\n", "\"", "\"");
if (c && strlen(c) > 0) SSM(SCI_SETKEYWORDS, number, (sptr_t)c);
continue;
}
}
DEL(line);
@ -321,7 +367,7 @@ static void writeEditorConfig(char *lexer, EditorDataT *self) {
case SC_TYPE_BOOLEAN:
fprintf(out, "boolean");
size = SSM(SCI_GETPROPERTYINT, (sptr_t)tags, 0);
config = utilCreateString("%s", size ? "true" : "false");
config = utilCreateString("%d", size);
break;
case SC_TYPE_STRING:

View file

@ -164,7 +164,7 @@ static void addToTree(ProjectDataT *self, char *filename) {
}
DEL(temp);
fileLen = 0;
utilEnsureBufferSize(&temp, &fileLen, 4); // fileLen is just a throwaway here.
utilEnsureBufferSize((unsigned char **)&temp, &fileLen, 4); // fileLen is just a throwaway here.
snprintf(temp, 4, "%d", foundAt);
gtk_tree_model_get_iter_from_string(model, &iter, temp);
gtk_tree_store_append(GTK_TREE_STORE(model), &child, &iter);
@ -195,7 +195,7 @@ static void loadConfig(ProjectDataT *self) {
if (utilFileExists(self->configName)) {
in = fopen(self->configName, "rt");
if (in != NULL) {
utilEnsureBufferSize(&line, &len, 1024); // Not technically needed, but fixes a pointer warning from memmaker.
utilEnsureBufferSize((unsigned char **)&line, (int *)&len, 1024); // Not technically needed, but fixes a pointer warning from memmaker.
while (getline(&line, &len, in) != -1) {
if (strlen(line) > 0) line[strlen(line) - 1] = 0;
switch (count) {
@ -276,7 +276,7 @@ static void loadProject(ProjectDataT *self) {
cwk_path_get_dirname(path, &i);
if (i > 0) path[i] = 0;
// Load config.
utilEnsureBufferSize(&line, &len, 1024); // Not technically needed, but fixes a pointer warning from memmaker.
utilEnsureBufferSize((unsigned char **)&line, (int *)&len, 1024); // Not technically needed, but fixes a pointer warning from memmaker.
while (getline(&line, &len, in) != -1) {
if (strlen(line) > 0) line[strlen(line) - 1] = 0;
c = utilGetToken(line, " ", "\"", "\"");

View file

@ -119,7 +119,7 @@ void utilEnsureBufferSize(unsigned char **buffer, int *length, int wanted) {
unsigned char *temp = NULL;
if (*length < wanted) {
*length = *length + 1024;
while (*length < wanted) *length = *length + 1024;
temp = realloc(*buffer, *length);
if (temp == NULL) {
//***TODO*** Something bad happened.
@ -449,7 +449,7 @@ void utilWindowRegister(gpointer windowData) {
int utilWindowsCloseAll(void) {
WindowDataT *w;
debug("Windows Left Open: %d\n", hmlen(_windowList));
debug("Windows Left Open: %ld\n", hmlen(_windowList));
while (hmlen(_windowList) > 0) {
w = (WindowDataT *)_windowList[0].value;
if (w->closeWindow(w->window, w) == TRUE) {
@ -476,7 +476,7 @@ gboolean utilWindowUnRegister(gpointer windowData) {
WindowDataT *w = (WindowDataT *)windowData;
result = hmdel(_windowList, w->window);
debug("Window Unregistered: %d\n", hmlen(_windowList));
debug("Window Unregistered: %ld\n", hmlen(_windowList));
DEL(w->filename);
DEL(w->title);

View file

@ -58,27 +58,27 @@ style 89 "inactive literal" "" fore 0xffffff
style 90 "inactive comment taskmarker" "" fore 0xffffff
style 91 "inactive literal string escapesequence" "" fore 0xffffff
property boolean styling.within.preprocessor "For C++ code, determines whether all preprocessor code is styled in the preprocessor style (0, the default) or only from the initial # to the end of the command word(1)." false
property boolean lexer.cpp.allow.dollars "Set to 0 to disallow the '$' character in identifiers with the cpp lexer." false
property boolean lexer.cpp.track.preprocessor "Set to 1 to interpret #if/#else/#endif to grey out code that is not active." true
property boolean lexer.cpp.update.preprocessor "Set to 1 to update preprocessor definitions when #define found." true
property boolean lexer.cpp.verbatim.strings.allow.escapes "Set to 1 to allow verbatim strings to contain escape sequences." true
property boolean lexer.cpp.triplequoted.strings "Set to 1 to enable highlighting of triple-quoted strings." false
property boolean lexer.cpp.hashquoted.strings "Set to 1 to enable highlighting of hash-quoted strings." false
property boolean lexer.cpp.backquoted.strings "Set to 1 to enable highlighting of back-quoted raw strings ." false
property boolean lexer.cpp.escape.sequence "Set to 1 to enable highlighting of escape sequences in strings" true
property boolean fold "" true
property boolean fold.cpp.syntax.based "Set this property to 0 to disable syntax based folding." true
property boolean fold.comment "This option enables folding multi-line comments and explicit fold points when using the C++ lexer. Explicit fold points allows adding extra folding by placing a //{ comment at the start and a //} at the end of a section that should fold." true
property boolean fold.cpp.comment.multiline "Set this property to 0 to disable folding multi-line comments when fold.comment=1." true
property boolean fold.cpp.comment.explicit "Set this property to 0 to disable folding explicit fold points when fold.comment=1." true
property boolean styling.within.preprocessor "For C++ code, determines whether all preprocessor code is styled in the preprocessor style (0, the default) or only from the initial # to the end of the command word(1)." 0
property boolean lexer.cpp.allow.dollars "Set to 0 to disallow the '$' character in identifiers with the cpp lexer." 0
property boolean lexer.cpp.track.preprocessor "Set to 1 to interpret #if/#else/#endif to grey out code that is not active." 1
property boolean lexer.cpp.update.preprocessor "Set to 1 to update preprocessor definitions when #define found." 1
property boolean lexer.cpp.verbatim.strings.allow.escapes "Set to 1 to allow verbatim strings to contain escape sequences." 1
property boolean lexer.cpp.triplequoted.strings "Set to 1 to enable highlighting of triple-quoted strings." 0
property boolean lexer.cpp.hashquoted.strings "Set to 1 to enable highlighting of hash-quoted strings." 0
property boolean lexer.cpp.backquoted.strings "Set to 1 to enable highlighting of back-quoted raw strings ." 0
property boolean lexer.cpp.escape.sequence "Set to 1 to enable highlighting of escape sequences in strings" 1
property boolean fold "" 1
property boolean fold.cpp.syntax.based "Set this property to 0 to disable syntax based folding." 1
property boolean fold.comment "This option enables folding multi-line comments and explicit fold points when using the C++ lexer. Explicit fold points allows adding extra folding by placing a //{ comment at the start and a //} at the end of a section that should fold." 1
property boolean fold.cpp.comment.multiline "Set this property to 0 to disable folding multi-line comments when fold.comment=1." 1
property boolean fold.cpp.comment.explicit "Set this property to 0 to disable folding explicit fold points when fold.comment=1." 1
property string fold.cpp.explicit.start "The string to use for explicit fold start points, replacing the standard //{." "//{"
property string fold.cpp.explicit.end "The string to use for explicit fold end points, replacing the standard //}." "//}"
property boolean fold.cpp.explicit.anywhere "Set this property to 1 to enable explicit fold points anywhere, not just in line comments." false
property boolean fold.cpp.preprocessor.at.else "This option enables folding on a preprocessor #else or #endif line of an #if statement." true
property boolean fold.preprocessor "This option enables folding preprocessor directives when using the C++ lexer. Includes C#'s explicit #region and #endregion folding directives." false
property boolean fold.compact "" false
property boolean fold.at.else "This option enables C++ folding on a "} else {" line of an if statement." true
property boolean fold.cpp.explicit.anywhere "Set this property to 1 to enable explicit fold points anywhere, not just in line comments." 0
property boolean fold.cpp.preprocessor.at.else "This option enables folding on a preprocessor #else or #endif line of an #if statement." 1
property boolean fold.preprocessor "This option enables folding preprocessor directives when using the C++ lexer. Includes C#'s explicit #region and #endregion folding directives." 0
property boolean fold.compact "" 0
property boolean fold.at.else "This option enables C++ folding on a "} else {" line of an if statement." 1
keywords 0 "Primary keywords and identifiers" auto break case char const continue default do double else enum extern float for goto if inline int long nullptr register restrict return short signed sizeof static struct switch typedef union unsigned void volitile while
keywords 1 "Secondary keywords and identifiers" jlFree jlMalloc jlRealloc jlDisplayBorder jlDisplayPresent jlDrawBlit8x8 jlDrawBlit8x8a jlDrawBlitMap jlDrawBox jlDrawBoxFilled jlDrawCircle jlDrawClear jlDrawColorGet jlDrawColorSet jlDrawEllipse jlDrawFill jlDrawFillTo jlDrawLine jlDrawPixelGet jlDrawPixelSet jlSurfaceGet jlSurfaceSet jlGameGetAxis jlGameGetButton jlImgCopy jlImgCreate jlImgDisplay jlImgFree jlImgLoad jlImgSave jlImgSurfaceGet jlKeyPressed jlKeyRead jlKeyWaitForAny jlModContinue jlModFree jlModIsPlaying jlModLoad jlModPause jlModPlay jlModStop jlModVolume jlPaletteDefault jlPaletteSet jlPaletteSetFromImg jlSoundFree jlSoundIsPlaying jlSoundLoad jlSoundPlay jlSoundStop jlSoundSwapChannels jlStnFree jlStnLoad jlUtilByteSwap jlUtilDie jlUtilIdle jlUtilInputRead jlUtilIsOdd jlUtilMakePathname jlUtilMustExit jlUtilNibbleSwap jlUtilRandom jlUtilRandomSeedGet jlUtilRandomSeedSet jlUtilSay jlUtilSleep jlUtilStackPop jlUtilStackPush jlUtilTimer jlUtilTimeSpan jlUtilTitleSet jlVecDisplay jlVecFree jlVecLoad