From db6f9d35c915d3e0c976415935f65706ea07c6a0 Mon Sep 17 00:00:00 2001 From: Scott Duensing Date: Sun, 29 Jan 2023 16:18:17 -0600 Subject: [PATCH] Code folding working. Not folding #ifdef for some reason. --- src/editor.c | 45 ++++++++++++----------------------- ui/editor-cpp.conf | 58 +++++++++++++++++++++++----------------------- 2 files changed, 44 insertions(+), 59 deletions(-) diff --git a/src/editor.c b/src/editor.c index c47c5b7..6aed97a 100644 --- a/src/editor.c +++ b/src/editor.c @@ -26,12 +26,6 @@ #include "scintillaHeaders.h" -typedef struct SyntaxHighlightingS { - int style; - int color; - char *description; -} SyntaxHighlightingT; - typedef struct EditorDataS { WindowDataT windowData; GtkWidget *boxForEditor; @@ -206,25 +200,6 @@ void winEditorCreate(void) { NULL, NULL }; - SyntaxHighlightingT cpp[] = { - { 0, 0x000000, "White Space" }, - { 1, 0x80807f,"Comment: /* */" }, - { 2, 0x80807f,"Line Comment: //" }, - { 3, 0x80807f,"Doc comment: block comments beginning with /** or /*!" }, - { 4, 0x6897b9,"Number" }, - { 5, 0xcc7832,"Keyword" }, - { 6, 0x6a8759,"Double-quoted string" }, - { 7, 0x6a8759,"Single-quoted string" }, - { 9, 0x8f8b25,"Preprocessor" }, - { 10, 0xffffff,"Operators" }, - { 11, 0x94b5c6,"Identifiers" }, - { 12, 0xff0000,"Error: End of line where string is not closed" }, - { 15, 0x80807f,"Doc Comment Line: line comments beginning with /// or //!." }, - { 25, 0x00ff00, "User defined literals" }, - { 27, 0x0000ff, "Escape sequence" }, - { 0, 0x000000, NULL } - }; - int i; // Set up instance data. self = NEW(EditorDataT); @@ -272,15 +247,25 @@ void winEditorCreate(void) { SSM(SCI_SETCARETFORE, 0x00ffff, 0); SSM(SCI_STYLESETBACK, STYLE_LINENUMBER, 0x222222); + SSM(SCI_SETFOLDMARGINCOLOUR, 1, 0x222222); + SSM(SCI_SETFOLDMARGINHICOLOUR, 1, 0x222222); + SSM(SCI_SETMARGINTYPEN, MARGIN_SCRIPT_FOLD_INDEX, SC_MARGIN_SYMBOL); + SSM(SCI_SETMARGINMASKN, MARGIN_SCRIPT_FOLD_INDEX, SC_MASK_FOLDERS); + SSM(SCI_SETMARGINWIDTHN, MARGIN_SCRIPT_FOLD_INDEX, 20); + SSM(SCI_SETMARGINSENSITIVEN, MARGIN_SCRIPT_FOLD_INDEX, 1); + SSM(SCI_MARKERDEFINE, SC_MARKNUM_FOLDEROPEN, SC_MARK_BOXMINUS); + SSM(SCI_MARKERDEFINE, SC_MARKNUM_FOLDER, SC_MARK_BOXPLUS); + SSM(SCI_MARKERDEFINE, SC_MARKNUM_FOLDERSUB, SC_MARK_VLINE); + SSM(SCI_MARKERDEFINE, SC_MARKNUM_FOLDERTAIL, SC_MARK_LCORNER); + SSM(SCI_MARKERDEFINE, SC_MARKNUM_FOLDEREND, SC_MARK_BOXPLUSCONNECTED); + SSM(SCI_MARKERDEFINE, SC_MARKNUM_FOLDEROPENMID, SC_MARK_BOXMINUSCONNECTED); + SSM(SCI_MARKERDEFINE, SC_MARKNUM_FOLDERMIDTAIL, SC_MARK_TCORNER); + SSM(SCI_SETFOLDFLAGS, SC_FOLDFLAG_LINEAFTER_CONTRACTED , 0); + // Add lexer for language support. self->pLexer = CreateLexer("cpp"); SSM(SCI_SETILEXER, 0, (sptr_t)self->pLexer); - // For now, just CPP. - for (i=0; cpp[i].description != NULL; i++) { - SSM(SCI_STYLESETFORE, cpp[i].style, cpp[i].color); - } - writeEditorConfig("cpp", self); loadEditorConfig("cpp", self); diff --git a/ui/editor-cpp.conf b/ui/editor-cpp.conf index 51f1d9e..ea3d5d7 100644 --- a/ui/editor-cpp.conf +++ b/ui/editor-cpp.conf @@ -29,36 +29,36 @@ style 25 "literal" "User defined literals" fore 0xffb86c style 26 "comment taskmarker" "Task Marker" fore 0xffffff style 27 "literal string escapesequence" "Escape sequence" fore 0xffffff -style 64 "inactive default" "" fore 0xffffff -style 65 "inactive comment" "" fore 0xffffff -style 66 "inactive comment line" "" fore 0xffffff -style 67 "inactive comment documentation" "" fore 0xffffff -style 68 "inactive literal numeric" "" fore 0xffffff -style 69 "inactive keyword" "" fore 0xffffff -style 70 "inactive literal string" "" fore 0xffffff -style 71 "inactive literal string character" "" fore 0xffffff -style 72 "inactive literal uuid" "" fore 0xffffff -style 73 "inactive preprocessor" "" fore 0xffffff -style 74 "inactive operator" "" fore 0xffffff -style 75 "inactive identifier" "" fore 0xffffff -style 76 "inactive error literal string" "" fore 0xffffff -style 77 "inactive literal string multiline raw" "" fore 0xffffff -style 78 "inactive literal regex" "" fore 0xffffff -style 79 "inactive comment documentation line" "" fore 0xffffff -style 80 "inactive identifier" "" fore 0xffffff -style 81 "inactive comment documentation keyword" "" fore 0xffffff -style 82 "inactive error comment documentation keyword" "" fore 0xffffff -style 83 "inactive identifier" "" fore 0xffffff -style 84 "inactive literal string multiline raw" "" fore 0xffffff -style 85 "inactive literal string multiline raw" "" fore 0xffffff -style 86 "inactive literal string" "" fore 0xffffff -style 87 "inactive comment preprocessor" "" fore 0xffffff -style 88 "inactive comment preprocessor documentation" "" fore 0xffffff -style 89 "inactive literal" "" fore 0xffffff -style 90 "inactive comment taskmarker" "" fore 0xffffff -style 91 "inactive literal string escapesequence" "" fore 0xffffff +style 64 "inactive default" "" fore 0x444444 +style 65 "inactive comment" "" fore 0x444444 +style 66 "inactive comment line" "" fore 0x444444 +style 67 "inactive comment documentation" "" fore 0x444444 +style 68 "inactive literal numeric" "" fore 0x444444 +style 69 "inactive keyword" "" fore 0x444444 +style 70 "inactive literal string" "" fore 0x444444 +style 71 "inactive literal string character" "" fore 0x444444 +style 72 "inactive literal uuid" "" fore 0x444444 +style 73 "inactive preprocessor" "" fore 0x444444 +style 74 "inactive operator" "" fore 0x444444 +style 75 "inactive identifier" "" fore 0x444444 +style 76 "inactive error literal string" "" fore 0x444444 +style 77 "inactive literal string multiline raw" "" fore 0x444444 +style 78 "inactive literal regex" "" fore 0x444444 +style 79 "inactive comment documentation line" "" fore 0x444444 +style 80 "inactive identifier" "" fore 0x444444 +style 81 "inactive comment documentation keyword" "" fore 0x444444 +style 82 "inactive error comment documentation keyword" "" fore 0x444444 +style 83 "inactive identifier" "" fore 0x444444 +style 84 "inactive literal string multiline raw" "" fore 0x444444 +style 85 "inactive literal string multiline raw" "" fore 0x444444 +style 86 "inactive literal string" "" fore 0x444444 +style 87 "inactive comment preprocessor" "" fore 0x444444 +style 88 "inactive comment preprocessor documentation" "" fore 0x444444 +style 89 "inactive literal" "" fore 0x444444 +style 90 "inactive comment taskmarker" "" fore 0x444444 +style 91 "inactive literal string escapesequence" "" fore 0x444444 -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 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)." 1 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