From bc11e5a1a19399ade24ec13b330973e6de28bba4 Mon Sep 17 00:00:00 2001 From: RaiKoHoff Date: Thu, 24 Sep 2020 12:21:18 +0200 Subject: [PATCH 1/5] + chg: using @zufuliu's EOL Mode detection enhancement (no SSE2 or AVX2 specializations) --- src/Edit.c | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/src/Edit.c b/src/Edit.c index 77524f928..d0aa96b17 100644 --- a/src/Edit.c +++ b/src/Edit.c @@ -862,24 +862,25 @@ void EditDetectEOLMode(LPCSTR lpData, size_t cbData, EditFileIOStatus* const sta // No NULL-terminated requirement for *ptr == '\n' const uint8_t* const end = (const uint8_t*)lpData + cbData - 1; + uint32_t const mask = (1 << '\r') | (1 << '\n'); do { // skip to line end - uint8_t ch; - uint8_t type = 0; - while (ptr < end && ((ch = *ptr++) > '\r' || (type = eol_table[ch]) == 0)) {} // nop - switch (type) { - case 1: //'\n' - ++lineCountLF; - break; - case 2: //'\r' - if (*ptr == '\n') { - ++ptr; - ++lineCountCRLF; - } - else { - ++lineCountCR; - } - break; + uint8_t ch = 0; + while (ptr < end && ((ch = *ptr++) > '\r' || ((mask >> ch) & 1) == 0)) { + // nop + } + switch (ch) { + case '\n': + ++lineCountLF; + break; + case '\r': + if (*ptr == '\n') { + ++ptr; + ++lineCountCRLF; + } else { + ++lineCountCR; + } + break; } } while (ptr < end); From ecb1c526634b6998e9707eb6cca9fb456bfc0456 Mon Sep 17 00:00:00 2001 From: RaiKoHoff Date: Thu, 24 Sep 2020 12:28:00 +0200 Subject: [PATCH 2/5] + upd: some RegEx engine fixes (current Oniguruma dev) --- scintilla/oniguruma/src/st.c | 8 ++++++-- scintilla/oniguruma/src/unicode.c | 13 ++++++------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/scintilla/oniguruma/src/st.c b/scintilla/oniguruma/src/st.c index 6d3dc6dc4..7471191be 100644 --- a/scintilla/oniguruma/src/st.c +++ b/scintilla/oniguruma/src/st.c @@ -152,6 +152,7 @@ st_init_table_with_size(type, size) #endif size = new_size(size); /* round up to prime number */ + if (size <= 0) return 0; tbl = alloc(st_table); if (tbl == 0) return 0; @@ -319,10 +320,13 @@ rehash(table) register st_table *table; { register st_table_entry *ptr, *next, **new_bins; - int i, old_num_bins = table->num_bins, new_num_bins; + int i, new_num_bins, old_num_bins; unsigned int hash_val; - new_num_bins = new_size(old_num_bins+1); + old_num_bins = table->num_bins; + new_num_bins = new_size(old_num_bins + 1); + if (new_num_bins <= 0) return ; + new_bins = (st_table_entry**)Calloc(new_num_bins, sizeof(st_table_entry*)); if (new_bins == 0) { return ; diff --git a/scintilla/oniguruma/src/unicode.c b/scintilla/oniguruma/src/unicode.c index fdc1ce46f..6855e04c9 100644 --- a/scintilla/oniguruma/src/unicode.c +++ b/scintilla/oniguruma/src/unicode.c @@ -388,15 +388,15 @@ onigenc_unicode_get_case_fold_codes_by_str(OnigEncoding enc, for (i = 0; i < ncs[0]; i++) { for (j = 0; j < ncs[1]; j++) { for (k = 0; k < ncs[2]; k++) { + if (cs[0][i] == orig_codes[0] && cs[1][j] == orig_codes[1] && + cs[2][k] == orig_codes[2]) + continue; + items[n].byte_len = lens[2]; items[n].code_len = 3; items[n].code[0] = cs[0][i]; items[n].code[1] = cs[1][j]; items[n].code[2] = cs[2][k]; - if (items[n].code[0] == orig_codes[0] && - items[n].code[1] == orig_codes[1] && - items[n].code[2] == orig_codes[2]) - continue; n++; } } @@ -432,13 +432,12 @@ onigenc_unicode_get_case_fold_codes_by_str(OnigEncoding enc, for (i = 0; i < ncs[0]; i++) { for (j = 0; j < ncs[1]; j++) { + if (cs[0][i] == orig_codes[0] && cs[1][j] == orig_codes[1]) + continue; items[n].byte_len = lens[1]; items[n].code_len = 2; items[n].code[0] = cs[0][i]; items[n].code[1] = cs[1][j]; - if (items[n].code[0] == orig_codes[0] && - items[n].code[1] == orig_codes[1]) - continue; n++; } } From e15ad9c1ec7bcdd1d8849760267e1ac23b5aa7b7 Mon Sep 17 00:00:00 2001 From: RaiKoHoff Date: Thu, 24 Sep 2020 16:15:48 +0200 Subject: [PATCH 3/5] + upd: prepare for Lexilla Library --- Notepad3.sln | 11 + lexilla/Lexilla.vcxproj | 245 ++++++++++++++++++++ lexilla/Lexilla.vcxproj.filters | 167 ++++++++++++++ lexilla/src/Lexilla.cxx | 345 ++++++++++++++++++++++++++++ lexilla/src/Lexilla.h | 19 ++ lexilla/src/LexillaVersion.rc | 37 +++ scintilla/Scintilla.vcxproj | 32 +-- scintilla/Scintilla.vcxproj.filters | 9 - scintilla/include/Scintilla.h | 2 + scintilla/src/Catalogue.cxx | 3 + src/Edit.c | 2 +- src/Notepad3.vcxproj | 11 +- src/StyleLexers/StyleLexers.h | 2 +- 13 files changed, 848 insertions(+), 37 deletions(-) create mode 100644 lexilla/Lexilla.vcxproj create mode 100644 lexilla/Lexilla.vcxproj.filters create mode 100644 lexilla/src/Lexilla.cxx create mode 100644 lexilla/src/Lexilla.h create mode 100644 lexilla/src/LexillaVersion.rc diff --git a/Notepad3.sln b/Notepad3.sln index 3f4e6d5ee..a87086b08 100644 --- a/Notepad3.sln +++ b/Notepad3.sln @@ -344,6 +344,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mp_es_mx", "minipath\langua {29AB36E1-284E-4E0B-9DF4-F4F84760BD9B} = {29AB36E1-284E-4E0B-9DF4-F4F84760BD9B} EndProjectSection EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Lexilla", "Lexilla\Lexilla.vcxproj", "{6D470002-E04D-4BBB-8B57-D20C2721FECE}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 @@ -788,6 +790,14 @@ Global {2AD33E48-FEC6-47B1-8FEF-A0CF1F23DD58}.Release|Win32.Build.0 = Release|Win32 {2AD33E48-FEC6-47B1-8FEF-A0CF1F23DD58}.Release|x64.ActiveCfg = Release|x64 {2AD33E48-FEC6-47B1-8FEF-A0CF1F23DD58}.Release|x64.Build.0 = Release|x64 + {6D470002-E04D-4BBB-8B57-D20C2721FECE}.Debug|Win32.ActiveCfg = Debug|Win32 + {6D470002-E04D-4BBB-8B57-D20C2721FECE}.Debug|Win32.Build.0 = Debug|Win32 + {6D470002-E04D-4BBB-8B57-D20C2721FECE}.Debug|x64.ActiveCfg = Debug|x64 + {6D470002-E04D-4BBB-8B57-D20C2721FECE}.Debug|x64.Build.0 = Debug|x64 + {6D470002-E04D-4BBB-8B57-D20C2721FECE}.Release|Win32.ActiveCfg = Release|Win32 + {6D470002-E04D-4BBB-8B57-D20C2721FECE}.Release|Win32.Build.0 = Release|Win32 + {6D470002-E04D-4BBB-8B57-D20C2721FECE}.Release|x64.ActiveCfg = Release|x64 + {6D470002-E04D-4BBB-8B57-D20C2721FECE}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -850,6 +860,7 @@ Global {CC891C3A-8A32-46EA-B80A-0D1DED2BCFB1} = {8FD783D5-8709-432D-A88E-6E3073AFF220} {B6757299-D2DD-4103-834D-45227AC13CB7} = {8C28F8E6-5B4E-4233-B5C7-5A903596AEB2} {2AD33E48-FEC6-47B1-8FEF-A0CF1F23DD58} = {8FD783D5-8709-432D-A88E-6E3073AFF220} + {6D470002-E04D-4BBB-8B57-D20C2721FECE} = {C3735E17-6EAE-4CC5-980E-30BCEF094862} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {C0B8FE68-ECBC-4173-9027-E1EC2C9B5BDF} diff --git a/lexilla/Lexilla.vcxproj b/lexilla/Lexilla.vcxproj new file mode 100644 index 000000000..46806f2f8 --- /dev/null +++ b/lexilla/Lexilla.vcxproj @@ -0,0 +1,245 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 16.0 + Win32Proj + {6d470002-e04d-4bbb-8b57-d20c2721fece} + Lexilla + 10.0 + Lexilla + + + + StaticLibrary + true + v142 + Unicode + + + StaticLibrary + false + v142 + true + Unicode + + + StaticLibrary + true + v142 + Unicode + + + StaticLibrary + false + v142 + true + Unicode + + + + + + + + + + + + + + + + + + + + + true + ..\Bin\$(Configuration)_$(PlatformShortName)_$(PlatformToolset)\obj\ + ..\Bin\$(Configuration)_$(PlatformShortName)_$(PlatformToolset)\obj\lexilla\ + + + false + ..\Bin\$(Configuration)_$(PlatformShortName)_$(PlatformToolset)\obj\ + ..\Bin\$(Configuration)_$(PlatformShortName)_$(PlatformToolset)\obj\lexilla\ + + + true + ..\Bin\$(Configuration)_$(PlatformShortName)_$(PlatformToolset)\obj\ + ..\Bin\$(Configuration)_$(PlatformShortName)_$(PlatformToolset)\obj\lexilla\ + + + false + ..\Bin\$(Configuration)_$(PlatformShortName)_$(PlatformToolset)\obj\ + ..\Bin\$(Configuration)_$(PlatformShortName)_$(PlatformToolset)\obj\lexilla\ + + + + Level3 + + + SCI_LEXER;_CRT_SECURE_NO_WARNINGS;STATIC_BUILD;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + stdcpp17 + true + ..\scintilla\include;..\scintilla\lexlib;src + true + Fast + + + Console + true + + + true + + + + + Level3 + true + true + + + SCI_LEXER;_CRT_SECURE_NO_WARNINGS;STATIC_BUILD;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + stdcpp17 + true + ..\scintilla\include;..\scintilla\lexlib;src + AnySuitable + Speed + true + Fast + StreamingSIMDExtensions2 + + + Console + true + true + true + + + true + + + + + Level3 + + + SCI_LEXER;_CRT_SECURE_NO_WARNINGS;STATIC_BUILD;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + stdcpp17 + true + ..\scintilla\include;..\scintilla\lexlib;src + true + Fast + + + Console + true + + + true + + + + + Level3 + true + true + + + SCI_LEXER;_CRT_SECURE_NO_WARNINGS;STATIC_BUILD;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + stdcpp17 + true + ..\scintilla\include;..\scintilla\lexlib;src + AnySuitable + Speed + true + Fast + + + Console + true + true + true + + + true + + + + + + \ No newline at end of file diff --git a/lexilla/Lexilla.vcxproj.filters b/lexilla/Lexilla.vcxproj.filters new file mode 100644 index 000000000..c58f9a161 --- /dev/null +++ b/lexilla/Lexilla.vcxproj.filters @@ -0,0 +1,167 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + {fa13b33a-f2d9-4d2f-8ad4-b03e597c2551} + + + {27c55e47-67fa-43d3-83f6-b9c801ea6532} + + + {0087651a-f9f8-4b96-a61b-9d58c9eedada} + + + + + Header Files + + + lexers_x + + + lexers_x + + + + + Source Files + + + lexers + + + lexers + + + lexers + + + lexers + + + lexers + + + lexers + + + lexers + + + lexers + + + lexers + + + lexers + + + lexers + + + lexers + + + lexers + + + lexers + + + lexers + + + lexers + + + lexers + + + lexers + + + lexers + + + lexers + + + lexers + + + lexers + + + lexers + + + lexers + + + lexers + + + lexers + + + lexers + + + lexers + + + lexers + + + lexers + + + lexers + + + lexers + + + lexers + + + lexers + + + lexers + + + lexers + + + lexers + + + lexers_x + + + lexers_x + + + lexers_x + + + + + Resource Files + + + \ No newline at end of file diff --git a/lexilla/src/Lexilla.cxx b/lexilla/src/Lexilla.cxx new file mode 100644 index 000000000..38875c1c1 --- /dev/null +++ b/lexilla/src/Lexilla.cxx @@ -0,0 +1,345 @@ +// Scintilla source code edit control +/** @file Lexilla.cxx + ** Lexer infrastructure. + ** Provides entry points to shared library. + **/ +// Copyright 2019 by Neil Hodgson +// The License.txt file describes the conditions under which this software may be distributed. + +#include + +#include + +#if _WIN32 +#define EXPORT_FUNCTION __declspec(dllexport) +#define CALLING_CONVENTION __stdcall +#else +#define EXPORT_FUNCTION __attribute__((visibility("default"))) +#define CALLING_CONVENTION +#endif + +#include "ILexer.h" + +#include "LexerModule.h" +#include "CatalogueModules.h" + +using namespace Scintilla; + +//extern LexerModule lmA68k; +//extern LexerModule lmAbaqus; +//extern LexerModule lmAda; +//extern LexerModule lmAPDL; +//extern LexerModule lmAs; + extern LexerModule lmAsm; +//extern LexerModule lmAsn1; +//extern LexerModule lmASY; + extern LexerModule lmAU3; +//extern LexerModule lmAVE; + extern LexerModule lmAVS; +//extern LexerModule lmBaan; + extern LexerModule lmBash; + extern LexerModule lmBatch; +//extern LexerModule lmBibTeX; +//extern LexerModule lmBlitzBasic; +//extern LexerModule lmBullant; +//extern LexerModule lmCaml; +//extern LexerModule lmCIL; +//extern LexerModule lmClw; +//extern LexerModule lmClwNoCase; + extern LexerModule lmCmake; +//extern LexerModule lmCOBOL; + extern LexerModule lmCoffeeScript; + extern LexerModule lmConf; + extern LexerModule lmCPP; + extern LexerModule lmCPPNoCase; +//extern LexerModule lmCsound; + extern LexerModule lmCss; + extern LexerModule lmD; +//extern LexerModule lmDataflex; + extern LexerModule lmDiff; +//extern LexerModule lmDMAP; +//extern LexerModule lmDMIS; +//extern LexerModule lmECL; +//extern LexerModule lmEDIFACT; +//extern LexerModule lmEiffel; +//extern LexerModule lmEiffelkw; +//extern LexerModule lmErlang; +//extern LexerModule lmErrorList; +//extern LexerModule lmESCRIPT; +//extern LexerModule lmF77; +//extern LexerModule lmFlagShip; +//extern LexerModule lmForth; +//extern LexerModule lmFortran; +//extern LexerModule lmFreeBasic; +//extern LexerModule lmGAP; +//extern LexerModule lmGui4Cli; +//extern LexerModule lmHaskell; +//extern LexerModule lmHollywood; + extern LexerModule lmHTML; +//extern LexerModule lmIHex; +//extern LexerModule lmIndent; + extern LexerModule lmInno; + extern LexerModule lmJSON; +//extern LexerModule lmKix; +//extern LexerModule lmKVIrc; + extern LexerModule lmLatex; +//extern LexerModule lmLISP; +//extern LexerModule lmLiterateHaskell; +//extern LexerModule lmLot; +//extern LexerModule lmLout; + extern LexerModule lmLua; +//extern LexerModule lmMagikSF; + extern LexerModule lmMake; + extern LexerModule lmMarkdown; + extern LexerModule lmMatlab; +//extern LexerModule lmMaxima; +//extern LexerModule lmMETAPOST; +//extern LexerModule lmMMIXAL; +//extern LexerModule lmModula; +//extern LexerModule lmMSSQL; +//extern LexerModule lmMySQL; + extern LexerModule lmNim; +//extern LexerModule lmNimrod; +//extern LexerModule lmNncrontab; + extern LexerModule lmNsis; + extern LexerModule lmNull; +//extern LexerModule lmOctave; +//extern LexerModule lmOpal; +//extern LexerModule lmOScript; + extern LexerModule lmPascal; +//extern LexerModule lmPB; + extern LexerModule lmPerl; +//extern LexerModule lmPHPSCRIPT; +//extern LexerModule lmPLM; +//extern LexerModule lmPO; +//extern LexerModule lmPOV; +//extern LexerModule lmPowerPro; + extern LexerModule lmPowerShell; +//extern LexerModule lmProgress; + extern LexerModule lmProps; +//extern LexerModule lmPS; +//extern LexerModule lmPureBasic; + extern LexerModule lmPython; + extern LexerModule lmR; +//extern LexerModule lmRaku; +//extern LexerModule lmREBOL; + extern LexerModule lmRegistry; + extern LexerModule lmRuby; + extern LexerModule lmRust; +//extern LexerModule lmSAS; +//extern LexerModule lmScriptol; +//extern LexerModule lmSmalltalk; +//extern LexerModule lmSML; +//extern LexerModule lmSorc; +//extern LexerModule lmSpecman; +//extern LexerModule lmSpice; + extern LexerModule lmSQL; +//extern LexerModule lmSrec; +//extern LexerModule lmStata; +//extern LexerModule lmSTTXT; +//extern LexerModule lmTACL; +//extern LexerModule lmTADS3; +//extern LexerModule lmTAL; + extern LexerModule lmTCL; +//extern LexerModule lmTCMD; +//extern LexerModule lmTEHex; +//extern LexerModule lmTeX; +//extern LexerModule lmTxt2tags; + extern LexerModule lmVB; + extern LexerModule lmVBScript; +//extern LexerModule lmVerilog; + extern LexerModule lmVHDL; +//extern LexerModule lmVisualProlog; +//extern LexerModule lmX12; + extern LexerModule lmXML; + extern LexerModule lmYAML; + +// --- custom lexers --- + + extern LexerModule lmAHKL; + extern LexerModule lmCSV; + extern LexerModule lmTOML; + + +namespace { + +CatalogueModules catalogueLexilla; + +void AddEachLexer() { + + if (catalogueLexilla.Count() > 0) { + return; + } + + //catalogueLexilla.AddLexerModule(&lmA68k); + //catalogueLexilla.AddLexerModule(&lmAbaqus); + //catalogueLexilla.AddLexerModule(&lmAda); + //catalogueLexilla.AddLexerModule(&lmAPDL); + //catalogueLexilla.AddLexerModule(&lmAs); + catalogueLexilla.AddLexerModule(&lmAsm); + //catalogueLexilla.AddLexerModule(&lmAsn1); + //catalogueLexilla.AddLexerModule(&lmASY); + catalogueLexilla.AddLexerModule(&lmAU3); + //catalogueLexilla.AddLexerModule(&lmAVE); + catalogueLexilla.AddLexerModule(&lmAVS); + //catalogueLexilla.AddLexerModule(&lmBaan); + catalogueLexilla.AddLexerModule(&lmBash); + catalogueLexilla.AddLexerModule(&lmBatch); + //catalogueLexilla.AddLexerModule(&lmBibTeX); + //catalogueLexilla.AddLexerModule(&lmBlitzBasic); + //catalogueLexilla.AddLexerModule(&lmBullant); + //catalogueLexilla.AddLexerModule(&lmCaml); + //catalogueLexilla.AddLexerModule(&lmCIL); + //catalogueLexilla.AddLexerModule(&lmClw); + //catalogueLexilla.AddLexerModule(&lmClwNoCase); + catalogueLexilla.AddLexerModule(&lmCmake); + //catalogueLexilla.AddLexerModule(&lmCOBOL); + catalogueLexilla.AddLexerModule(&lmCoffeeScript); + catalogueLexilla.AddLexerModule(&lmConf); + catalogueLexilla.AddLexerModule(&lmCPP); + catalogueLexilla.AddLexerModule(&lmCPPNoCase); + //catalogueLexilla.AddLexerModule(&lmCsound); + catalogueLexilla.AddLexerModule(&lmCss); + catalogueLexilla.AddLexerModule(&lmD); + //catalogueLexilla.AddLexerModule(&lmDataflex); + catalogueLexilla.AddLexerModule(&lmDiff); + //catalogueLexilla.AddLexerModule(&lmDMAP); + //catalogueLexilla.AddLexerModule(&lmDMIS); + //catalogueLexilla.AddLexerModule(&lmECL); + //catalogueLexilla.AddLexerModule(&lmEDIFACT); + //catalogueLexilla.AddLexerModule(&lmEiffel); + //catalogueLexilla.AddLexerModule(&lmEiffelkw); + //catalogueLexilla.AddLexerModule(&lmErlang); + //catalogueLexilla.AddLexerModule(&lmErrorList); + //catalogueLexilla.AddLexerModule(&lmESCRIPT); + //catalogueLexilla.AddLexerModule(&lmF77); + //catalogueLexilla.AddLexerModule(&lmFlagShip); + //catalogueLexilla.AddLexerModule(&lmForth); + //catalogueLexilla.AddLexerModule(&lmFortran); + //catalogueLexilla.AddLexerModule(&lmFreeBasic); + //catalogueLexilla.AddLexerModule(&lmGAP); + //catalogueLexilla.AddLexerModule(&lmGui4Cli); + //catalogueLexilla.AddLexerModule(&lmHaskell); + //catalogueLexilla.AddLexerModule(&lmHollywood); + catalogueLexilla.AddLexerModule(&lmHTML); + //catalogueLexilla.AddLexerModule(&lmIHex); + //catalogueLexilla.AddLexerModule(&lmIndent); + catalogueLexilla.AddLexerModule(&lmInno); + catalogueLexilla.AddLexerModule(&lmJSON); + //catalogueLexilla.AddLexerModule(&lmKix); + //catalogueLexilla.AddLexerModule(&lmKVIrc); + catalogueLexilla.AddLexerModule(&lmLatex); + //catalogueLexilla.AddLexerModule(&lmLISP); + //catalogueLexilla.AddLexerModule(&lmLiterateHaskell); + //catalogueLexilla.AddLexerModule(&lmLot); + //catalogueLexilla.AddLexerModule(&lmLout); + catalogueLexilla.AddLexerModule(&lmLua); + //catalogueLexilla.AddLexerModule(&lmMagikSF); + catalogueLexilla.AddLexerModule(&lmMake); + catalogueLexilla.AddLexerModule(&lmMarkdown); + catalogueLexilla.AddLexerModule(&lmMatlab); + //catalogueLexilla.AddLexerModule(&lmMaxima); + //catalogueLexilla.AddLexerModule(&lmMETAPOST); + //catalogueLexilla.AddLexerModule(&lmMMIXAL); + //catalogueLexilla.AddLexerModule(&lmModula); + //catalogueLexilla.AddLexerModule(&lmMSSQL); + //catalogueLexilla.AddLexerModule(&lmMySQL); + catalogueLexilla.AddLexerModule(&lmNim); + //catalogueLexilla.AddLexerModule(&lmNimrod); + //catalogueLexilla.AddLexerModule(&lmNncrontab); + catalogueLexilla.AddLexerModule(&lmNsis); + catalogueLexilla.AddLexerModule(&lmNull); + //catalogueLexilla.AddLexerModule(&lmOctave); + //catalogueLexilla.AddLexerModule(&lmOpal); + //catalogueLexilla.AddLexerModule(&lmOScript); + catalogueLexilla.AddLexerModule(&lmPascal); + //catalogueLexilla.AddLexerModule(&lmPB); + catalogueLexilla.AddLexerModule(&lmPerl); + //catalogueLexilla.AddLexerModule(&lmPHPSCRIPT); + //catalogueLexilla.AddLexerModule(&lmPLM); + //catalogueLexilla.AddLexerModule(&lmPO); + //catalogueLexilla.AddLexerModule(&lmPOV); + //catalogueLexilla.AddLexerModule(&lmPowerPro); + catalogueLexilla.AddLexerModule(&lmPowerShell); + //catalogueLexilla.AddLexerModule(&lmProgress); + catalogueLexilla.AddLexerModule(&lmProps); + //catalogueLexilla.AddLexerModule(&lmPS); + //catalogueLexilla.AddLexerModule(&lmPureBasic); + catalogueLexilla.AddLexerModule(&lmPython); + catalogueLexilla.AddLexerModule(&lmR); + //catalogueLexilla.AddLexerModule(&lmRaku); + //catalogueLexilla.AddLexerModule(&lmREBOL); + catalogueLexilla.AddLexerModule(&lmRegistry); + catalogueLexilla.AddLexerModule(&lmRuby); + catalogueLexilla.AddLexerModule(&lmRust); + //catalogueLexilla.AddLexerModule(&lmSAS); + //catalogueLexilla.AddLexerModule(&lmScriptol); + //catalogueLexilla.AddLexerModule(&lmSmalltalk); + //catalogueLexilla.AddLexerModule(&lmSML); + //catalogueLexilla.AddLexerModule(&lmSorc); + //catalogueLexilla.AddLexerModule(&lmSpecman); + //catalogueLexilla.AddLexerModule(&lmSpice); + catalogueLexilla.AddLexerModule(&lmSQL); + //catalogueLexilla.AddLexerModule(&lmSrec); + //catalogueLexilla.AddLexerModule(&lmStata); + //catalogueLexilla.AddLexerModule(&lmSTTXT); + //catalogueLexilla.AddLexerModule(&lmTACL); + //catalogueLexilla.AddLexerModule(&lmTADS3); + //catalogueLexilla.AddLexerModule(&lmTAL); + catalogueLexilla.AddLexerModule(&lmTCL); + //catalogueLexilla.AddLexerModule(&lmTCMD); + //catalogueLexilla.AddLexerModule(&lmTEHex); + //catalogueLexilla.AddLexerModule(&lmTeX); + //catalogueLexilla.AddLexerModule(&lmTxt2tags); + catalogueLexilla.AddLexerModule(&lmVB); + catalogueLexilla.AddLexerModule(&lmVBScript); + //catalogueLexilla.AddLexerModule(&lmVerilog); + catalogueLexilla.AddLexerModule(&lmVHDL); + //catalogueLexilla.AddLexerModule(&lmVisualProlog); + //catalogueLexilla.AddLexerModule(&lmX12); + catalogueLexilla.AddLexerModule(&lmXML); + catalogueLexilla.AddLexerModule(&lmYAML); + + // --- custom lexers --- + + catalogueLexilla.AddLexerModule(&lmAHKL); + catalogueLexilla.AddLexerModule(&lmCSV); + catalogueLexilla.AddLexerModule(&lmTOML); + +} + +} + +extern "C" { + +EXPORT_FUNCTION int CALLING_CONVENTION GetLexerCount() { + AddEachLexer(); + return catalogueLexilla.Count(); +} + +EXPORT_FUNCTION void CALLING_CONVENTION GetLexerName(unsigned int index, char *name, int buflength) { + AddEachLexer(); + *name = 0; + const char *lexerName = catalogueLexilla.Name(index); + if (static_cast(buflength) > strlen(lexerName)) { + strcpy(name, lexerName); + } +} + +EXPORT_FUNCTION LexerFactoryFunction CALLING_CONVENTION GetLexerFactory(unsigned int index) { + AddEachLexer(); + return catalogueLexilla.Factory(index); +} + +EXPORT_FUNCTION ILexer5 * CALLING_CONVENTION CreateLexer(const char *name) { + AddEachLexer(); + for (unsigned int i = 0; i < catalogueLexilla.Count(); i++) { + const char *lexerName = catalogueLexilla.Name(i); + if (0 == strcmp(lexerName, name)) { + return catalogueLexilla.Create(i); + } + } + return nullptr; +} + +} diff --git a/lexilla/src/Lexilla.h b/lexilla/src/Lexilla.h new file mode 100644 index 000000000..92b6378c0 --- /dev/null +++ b/lexilla/src/Lexilla.h @@ -0,0 +1,19 @@ +// Scintilla source code edit control +/** @file Lexilla.h + ** Lexer infrastructure. + ** Declare functions in Lexilla library. + **/ +// Copyright 2019 by Neil Hodgson +// The License.txt file describes the conditions under which this software may be distributed. + +#if _WIN32 +#define LEXILLA_CALLING_CONVENTION __stdcall +#else +#define LEXILLA_CALLING_CONVENTION +#endif + +extern "C" { + +Scintilla::ILexer5 * LEXILLA_CALLING_CONVENTION CreateLexer(const char *name); + +} diff --git a/lexilla/src/LexillaVersion.rc b/lexilla/src/LexillaVersion.rc new file mode 100644 index 000000000..78d5931dd --- /dev/null +++ b/lexilla/src/LexillaVersion.rc @@ -0,0 +1,37 @@ +// Resource file for Lexilla - provides a version number +// Copyright 2020 by Neil Hodgson +// The License.txt file describes the conditions under which this software may be distributed. + +#include + +#define VERSION_LEXILLA "4.4.5" +#define VERSION_WORDS 4, 4, 5, 0 + +VS_VERSION_INFO VERSIONINFO +FILEVERSION VERSION_WORDS +PRODUCTVERSION VERSION_WORDS +FILEFLAGSMASK 0x3fL +FILEFLAGS 0 +FILEOS VOS_NT_WINDOWS32 +FILETYPE VFT_APP +FILESUBTYPE VFT2_UNKNOWN +BEGIN + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "CompanyName", "Neil Hodgson neilh@scintilla.org\0" + VALUE "FileDescription", "Lexilla.lib - a Lexical Analysis Component\0" + VALUE "FileVersion", VERSION_LEXILLA "\0" + VALUE "InternalName", "Lexilla\0" + VALUE "LegalCopyright", "Copyright 2019 by Neil Hodgson\0" + VALUE "OriginalFilename", "Lexilla.lib\0" + VALUE "ProductName", "Lexilla\0" + VALUE "ProductVersion", VERSION_LEXILLA "\0" + END + END +END diff --git a/scintilla/Scintilla.vcxproj b/scintilla/Scintilla.vcxproj index a3ea16d4e..00c838ae7 100644 --- a/scintilla/Scintilla.vcxproj +++ b/scintilla/Scintilla.vcxproj @@ -31,12 +31,14 @@ StaticLibrary v141 v142 + true Unicode StaticLibrary v141 v142 + true Unicode @@ -121,15 +123,15 @@ true Disabled NotUsing - _WIN32_WINNT=0x601;WINVER=0x601;NTDDI_VERSION=0x06010000;_SCL_SECURE_NO_WARNINGS;NP3;NO_CXX11_REGEX;SCI_OWNREGEX;ONIG_STATIC;WIN32;_DEBUG;_WINDOWS;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES;STATIC_BUILD;SCI_LEXER;USE_D2D;%(PreprocessorDefinitions) + _WIN32_WINNT=0x601;WINVER=0x601;NTDDI_VERSION=0x06010000;_SCL_SECURE_NO_WARNINGS;NP3;NO_CXX11_REGEX;SCI_OWNREGEX;ONIG_STATIC;SCI_LEXER;WIN32;_DEBUG;_WINDOWS;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES;STATIC_BUILD;USE_D2D;%(PreprocessorDefinitions) MultiThreadedDebug Level3 false true - StreamingSIMDExtensions2 + NotSet Fast - stdcpplatest + stdcpp17 true @@ -146,13 +148,13 @@ true Disabled NotUsing - _WIN32_WINNT=0x601;WINVER=0x601;NTDDI_VERSION=0x06010000;_SCL_SECURE_NO_WARNINGS;NP3;NO_CXX11_REGEX;SCI_OWNREGEX;ONIG_STATIC;_WIN64;_DEBUG;_WINDOWS;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES;STATIC_BUILD;SCI_LEXER;USE_D2D;%(PreprocessorDefinitions) + _WIN32_WINNT=0x601;WINVER=0x601;NTDDI_VERSION=0x06010000;_SCL_SECURE_NO_WARNINGS;NP3;NO_CXX11_REGEX;SCI_OWNREGEX;ONIG_STATIC;SCI_LEXER;_WIN64;_DEBUG;_WINDOWS;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES;STATIC_BUILD;USE_D2D;%(PreprocessorDefinitions) MultiThreadedDebug Level3 false true Fast - stdcpplatest + stdcpp17 MachineX64 @@ -170,13 +172,13 @@ true MaxSpeed NotUsing - _WIN32_WINNT=0x601;WINVER=0x601;NTDDI_VERSION=0x06010000;_SCL_SECURE_NO_WARNINGS;NP3;NO_CXX11_REGEX;SCI_OWNREGEX;ONIG_STATIC;WIN32;NDEBUG;_WINDOWS;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES;STATIC_BUILD;SCI_LEXER;USE_D2D;%(PreprocessorDefinitions) + _WIN32_WINNT=0x601;WINVER=0x601;NTDDI_VERSION=0x06010000;_SCL_SECURE_NO_WARNINGS;NP3;NO_CXX11_REGEX;SCI_OWNREGEX;ONIG_STATIC;SCI_LEXER;WIN32;NDEBUG;_WINDOWS;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES;STATIC_BUILD;USE_D2D;%(PreprocessorDefinitions) MultiThreaded Level3 true Fast - stdcpplatest + stdcpp17 Speed true AnySuitable @@ -193,12 +195,12 @@ true MaxSpeed NotUsing - _WIN32_WINNT=0x601;WINVER=0x601;NTDDI_VERSION=0x06010000;_SCL_SECURE_NO_WARNINGS;NP3;NO_CXX11_REGEX;SCI_OWNREGEX;ONIG_STATIC;_WIN64;NDEBUG;_WINDOWS;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES;STATIC_BUILD;SCI_LEXER;USE_D2D;%(PreprocessorDefinitions) + _WIN32_WINNT=0x601;WINVER=0x601;NTDDI_VERSION=0x06010000;_SCL_SECURE_NO_WARNINGS;NP3;NO_CXX11_REGEX;SCI_OWNREGEX;ONIG_STATIC;SCI_LEXER;_WIN64;NDEBUG;_WINDOWS;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES;STATIC_BUILD;USE_D2D;%(PreprocessorDefinitions) MultiThreaded Level3 true Fast - stdcpplatest + stdcpp17 Speed true AnySuitable @@ -273,12 +275,6 @@ - - true - true - true - true - @@ -340,12 +336,6 @@ - - true - true - true - true - diff --git a/scintilla/Scintilla.vcxproj.filters b/scintilla/Scintilla.vcxproj.filters index 397fd87be..8fb1765f0 100644 --- a/scintilla/Scintilla.vcxproj.filters +++ b/scintilla/Scintilla.vcxproj.filters @@ -19,9 +19,6 @@ {97da2683-9a5a-42f9-8ac6-0e8c54ce61e7} - - {326090d3-060e-4529-9b3e-4be7793fb194} - {3e51698b-084e-40cf-8dee-860bd61d7a2c} @@ -276,9 +273,6 @@ src - - lexilla - lexers_x @@ -539,9 +533,6 @@ src - - lexilla - lexers_x diff --git a/scintilla/include/Scintilla.h b/scintilla/include/Scintilla.h index 98abbc0b1..c54a79104 100644 --- a/scintilla/include/Scintilla.h +++ b/scintilla/include/Scintilla.h @@ -31,7 +31,9 @@ __declspec(dllexport) int Scintilla_GetSystemMetricsForDpi(int nIndex, DPI_T d __declspec(dllexport) int Scintilla_AdjustWindowRectForDpi(WRCT_T* lpRect, unsigned long dwStyle, unsigned long dwExStyle, DPI_T dpi); // <<<<<<<<<<<<<<< END NON STD SCI PATCH <<<<<<<<<<<<<<< +#ifdef SCI_LEXER int Scintilla_LinkLexers(void); +#endif #ifdef __cplusplus } diff --git a/scintilla/src/Catalogue.cxx b/scintilla/src/Catalogue.cxx index c40bf05a3..499b1a705 100644 --- a/scintilla/src/Catalogue.cxx +++ b/scintilla/src/Catalogue.cxx @@ -46,6 +46,7 @@ void Catalogue::AddLexerModule(LexerModule *plm) { // Force a reference to all of the Scintilla lexers so that the linker will // not remove the code of the lexers. +#ifdef SCI_LEXER int Scintilla_LinkLexers() { static int initialised = 0; @@ -200,3 +201,5 @@ int Scintilla_LinkLexers() { return 1; } +#endif // SCI_LEXER + diff --git a/src/Edit.c b/src/Edit.c index d0aa96b17..bfe51d16d 100644 --- a/src/Edit.c +++ b/src/Edit.c @@ -40,7 +40,7 @@ #include "DarkMode/DarkMode.h" #include "SciCall.h" -#include "SciLexer.h" +//#include "SciLexer.h" #include "Edit.h" diff --git a/src/Notepad3.vcxproj b/src/Notepad3.vcxproj index d3dee9943..d03cda363 100644 --- a/src/Notepad3.vcxproj +++ b/src/Notepad3.vcxproj @@ -115,7 +115,7 @@ false true true - StreamingSIMDExtensions2 + NotSet Fast stdcpp17 false @@ -123,7 +123,7 @@ Async - comctl32.lib;imm32.lib;shlwapi.lib;uxtheme.lib;muiload.lib;scintilla.lib;%(AdditionalDependencies) + comctl32.lib;imm32.lib;shlwapi.lib;uxtheme.lib;muiload.lib;scintilla.lib;lexilla.lib;%(AdditionalDependencies) Debug Windows MachineX86 @@ -188,7 +188,7 @@ Async - comctl32.lib;imm32.lib;shlwapi.lib;uxtheme.lib;muiload.lib;scintilla.lib;%(AdditionalDependencies) + comctl32.lib;imm32.lib;shlwapi.lib;uxtheme.lib;muiload.lib;scintilla.lib;lexilla.lib;%(AdditionalDependencies) Debug Windows MachineX64 @@ -253,9 +253,10 @@ Async true false + StreamingSIMDExtensions2 - comctl32.lib;imm32.lib;shlwapi.lib;uxtheme.lib;muiload.lib;scintilla.lib;%(AdditionalDependencies) + comctl32.lib;imm32.lib;shlwapi.lib;uxtheme.lib;muiload.lib;scintilla.lib;lexilla.lib;%(AdditionalDependencies) No .rdata=.text true @@ -326,7 +327,7 @@ false - comctl32.lib;imm32.lib;shlwapi.lib;uxtheme.lib;muiload.lib;scintilla.lib;%(AdditionalDependencies) + comctl32.lib;imm32.lib;shlwapi.lib;uxtheme.lib;muiload.lib;scintilla.lib;lexilla.lib;%(AdditionalDependencies) No .rdata=.text true diff --git a/src/StyleLexers/StyleLexers.h b/src/StyleLexers/StyleLexers.h index 05025f596..9b4bbff19 100644 --- a/src/StyleLexers/StyleLexers.h +++ b/src/StyleLexers/StyleLexers.h @@ -7,7 +7,7 @@ #include "Scintilla.h" #include "SciLexer.h" -#include "../scintilla/lexers_x/SciXLexer.h" +#include "lexers_x/SciXLexer.h" #include "resource.h" From 61817e56b20ce157791dcc671d0df8b1d402880c Mon Sep 17 00:00:00 2001 From: Rainer Kottenhoff Date: Fri, 25 Sep 2020 01:09:42 +0200 Subject: [PATCH 4/5] + chg: Scintilla 5 prep: Using ILexer5 interface from static build Lexilla.lib --- lexilla/Lexilla.vcxproj | 4 + lexilla/src/Lexilla.cxx | 36 ++++++-- lexilla/src/Lexilla.h | 9 +- scintilla/Scintilla.vcxproj | 48 +--------- scintilla/Scintilla.vcxproj.filters | 132 ---------------------------- scintilla/lexers_x/LexAHKL.cxx | 2 +- scintilla/lexlib/CatalogueModules.h | 8 ++ src/Notepad3.vcxproj | 8 +- src/SciCall.h | 6 +- src/StyleLexers/EditLexer.h | 16 ++-- src/Styles.c | 42 +++++---- 11 files changed, 91 insertions(+), 220 deletions(-) diff --git a/lexilla/Lexilla.vcxproj b/lexilla/Lexilla.vcxproj index 46806f2f8..de88ecddb 100644 --- a/lexilla/Lexilla.vcxproj +++ b/lexilla/Lexilla.vcxproj @@ -154,6 +154,7 @@ ..\scintilla\include;..\scintilla\lexlib;src true Fast + MultiThreadedDebug Console @@ -180,6 +181,7 @@ true Fast StreamingSIMDExtensions2 + MultiThreaded Console @@ -203,6 +205,7 @@ ..\scintilla\include;..\scintilla\lexlib;src true Fast + MultiThreadedDebug Console @@ -228,6 +231,7 @@ Speed true Fast + MultiThreaded Console diff --git a/lexilla/src/Lexilla.cxx b/lexilla/src/Lexilla.cxx index 38875c1c1..880419d28 100644 --- a/lexilla/src/Lexilla.cxx +++ b/lexilla/src/Lexilla.cxx @@ -7,15 +7,23 @@ // The License.txt file describes the conditions under which this software may be distributed. #include - #include #if _WIN32 + +#ifdef DLL_EXPORT #define EXPORT_FUNCTION __declspec(dllexport) -#define CALLING_CONVENTION __stdcall #else +#define EXPORT_FUNCTION +#endif // DLL_EXPORT + +#define CALLING_CONVENTION __stdcall + +#else + #define EXPORT_FUNCTION __attribute__((visibility("default"))) #define CALLING_CONVENTION + #endif #include "ILexer.h" @@ -175,7 +183,7 @@ void AddEachLexer() { //catalogueLexilla.AddLexerModule(&lmAbaqus); //catalogueLexilla.AddLexerModule(&lmAda); //catalogueLexilla.AddLexerModule(&lmAPDL); - //catalogueLexilla.AddLexerModule(&lmAs); + // catalogueLexilla.AddLexerModule(&lmAs); catalogueLexilla.AddLexerModule(&lmAsm); //catalogueLexilla.AddLexerModule(&lmAsn1); //catalogueLexilla.AddLexerModule(&lmASY); @@ -317,7 +325,7 @@ EXPORT_FUNCTION int CALLING_CONVENTION GetLexerCount() { return catalogueLexilla.Count(); } -EXPORT_FUNCTION void CALLING_CONVENTION GetLexerName(unsigned int index, char *name, int buflength) { +EXPORT_FUNCTION void CALLING_CONVENTION GetLexerName(unsigned int index, char* name, int buflength) { AddEachLexer(); *name = 0; const char *lexerName = catalogueLexilla.Name(index); @@ -331,15 +339,27 @@ EXPORT_FUNCTION LexerFactoryFunction CALLING_CONVENTION GetLexerFactory(unsigned return catalogueLexilla.Factory(index); } -EXPORT_FUNCTION ILexer5 * CALLING_CONVENTION CreateLexer(const char *name) { + +EXPORT_FUNCTION void /*ILexer5*/* CALLING_CONVENTION CreateLexerByID(const int language) { + AddEachLexer(); + for (unsigned int i = 0; i < catalogueLexilla.Count(); i++) { + const int lngID = catalogueLexilla.LngID(i); + if (language == lngID) { + return (void*)catalogueLexilla.Create(i); + } + } + return (void*)nullptr; +} + +EXPORT_FUNCTION void /*ILexer5*/ * CALLING_CONVENTION CreateLexerByName(const char* name) { AddEachLexer(); for (unsigned int i = 0; i < catalogueLexilla.Count(); i++) { const char *lexerName = catalogueLexilla.Name(i); if (0 == strcmp(lexerName, name)) { - return catalogueLexilla.Create(i); + return (void*)catalogueLexilla.Create(i); } } - return nullptr; + return (void*)nullptr; } -} +} // extern "C" diff --git a/lexilla/src/Lexilla.h b/lexilla/src/Lexilla.h index 92b6378c0..b3ba2e791 100644 --- a/lexilla/src/Lexilla.h +++ b/lexilla/src/Lexilla.h @@ -12,8 +12,13 @@ #define LEXILLA_CALLING_CONVENTION #endif +#ifdef _cplusplus extern "C" { +#endif -Scintilla::ILexer5 * LEXILLA_CALLING_CONVENTION CreateLexer(const char *name); +void /*ILexer5*/ * LEXILLA_CALLING_CONVENTION CreateLexerByID(const int language); +void /*ILexer5*/ * LEXILLA_CALLING_CONVENTION CreateLexerByName(const char* name); -} +#ifdef _cplusplus +} // extern "C" +#endif diff --git a/scintilla/Scintilla.vcxproj b/scintilla/Scintilla.vcxproj index 00c838ae7..baa235e93 100644 --- a/scintilla/Scintilla.vcxproj +++ b/scintilla/Scintilla.vcxproj @@ -123,7 +123,7 @@ true Disabled NotUsing - _WIN32_WINNT=0x601;WINVER=0x601;NTDDI_VERSION=0x06010000;_SCL_SECURE_NO_WARNINGS;NP3;NO_CXX11_REGEX;SCI_OWNREGEX;ONIG_STATIC;SCI_LEXER;WIN32;_DEBUG;_WINDOWS;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES;STATIC_BUILD;USE_D2D;%(PreprocessorDefinitions) + _WIN32_WINNT=0x601;WINVER=0x601;NTDDI_VERSION=0x06010000;_SCL_SECURE_NO_WARNINGS;NP3;NO_CXX11_REGEX;SCI_OWNREGEX;ONIG_STATIC;WIN32;_DEBUG;_WINDOWS;_CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES;USE_D2D;%(PreprocessorDefinitions) MultiThreadedDebug Level3 false @@ -148,7 +148,7 @@ true Disabled NotUsing - _WIN32_WINNT=0x601;WINVER=0x601;NTDDI_VERSION=0x06010000;_SCL_SECURE_NO_WARNINGS;NP3;NO_CXX11_REGEX;SCI_OWNREGEX;ONIG_STATIC;SCI_LEXER;_WIN64;_DEBUG;_WINDOWS;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES;STATIC_BUILD;USE_D2D;%(PreprocessorDefinitions) + _WIN32_WINNT=0x601;WINVER=0x601;NTDDI_VERSION=0x06010000;_SCL_SECURE_NO_WARNINGS;NP3;NO_CXX11_REGEX;SCI_OWNREGEX;ONIG_STATIC;_WIN64;_DEBUG;_WINDOWS;_CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES;USE_D2D;%(PreprocessorDefinitions) MultiThreadedDebug Level3 false @@ -172,7 +172,7 @@ true MaxSpeed NotUsing - _WIN32_WINNT=0x601;WINVER=0x601;NTDDI_VERSION=0x06010000;_SCL_SECURE_NO_WARNINGS;NP3;NO_CXX11_REGEX;SCI_OWNREGEX;ONIG_STATIC;SCI_LEXER;WIN32;NDEBUG;_WINDOWS;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES;STATIC_BUILD;USE_D2D;%(PreprocessorDefinitions) + _WIN32_WINNT=0x601;WINVER=0x601;NTDDI_VERSION=0x06010000;_SCL_SECURE_NO_WARNINGS;NP3;NO_CXX11_REGEX;SCI_OWNREGEX;ONIG_STATIC;WIN32;NDEBUG;_WINDOWS;_CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES;USE_D2D;%(PreprocessorDefinitions) MultiThreaded Level3 true @@ -235,46 +235,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -328,8 +288,6 @@ - - diff --git a/scintilla/Scintilla.vcxproj.filters b/scintilla/Scintilla.vcxproj.filters index 8fb1765f0..2b74260c4 100644 --- a/scintilla/Scintilla.vcxproj.filters +++ b/scintilla/Scintilla.vcxproj.filters @@ -4,9 +4,6 @@ {b78c6486-26fc-4890-89c0-f7f3e301b79c} - - {6b8793d0-aa9c-432f-aa65-b763bc23ae40} - {b4579e25-25b5-4f0d-8dab-c34ed9f53913} @@ -19,9 +16,6 @@ {97da2683-9a5a-42f9-8ac6-0e8c54ce61e7} - - {3e51698b-084e-40cf-8dee-860bd61d7a2c} - {32ffd4ad-2b04-4d07-acff-dad68cf258de} @@ -30,96 +24,6 @@ - - lexers - - - lexers - - - lexers - - - lexers - - - lexers - - - lexers - - - lexers - - - lexers - - - lexers - - - lexers - - - lexers - - - lexers - - - lexers - - - lexers - - - lexers - - - lexers - - - lexers - - - lexers - - - lexers - - - lexers - - - lexers - - - lexers - - - lexers - - - lexers - - - lexers - - - lexers - - - lexers - - - lexers - - - lexers - - - lexers - lexlib @@ -243,45 +147,15 @@ win32 - - lexers - - - lexers - - - lexers - src lexlib - - lexers - - - lexers - - - lexers - - - lexers - src - - lexers_x - - - lexers_x - - - lexers_x - oniguruma\scintilla @@ -533,12 +407,6 @@ src - - lexers_x - - - lexers_x - oniguruma\src diff --git a/scintilla/lexers_x/LexAHKL.cxx b/scintilla/lexers_x/LexAHKL.cxx index 9a0057706..669739737 100644 --- a/scintilla/lexers_x/LexAHKL.cxx +++ b/scintilla/lexers_x/LexAHKL.cxx @@ -782,4 +782,4 @@ void SCI_METHOD LexerAHKL::Fold(Sci_PositionU startPos, Sci_Position lengthDoc, } -LexerModule lmAHKL(SCLEX_AHKL, LexerAHKL::LexerFactoryAHKL, "ahk; ahkl", ahklWordLists); +LexerModule lmAHKL(SCLEX_AHKL, LexerAHKL::LexerFactoryAHKL, "ahkl", ahklWordLists); diff --git a/scintilla/lexlib/CatalogueModules.h b/scintilla/lexlib/CatalogueModules.h index 267a7b82b..264999fd5 100644 --- a/scintilla/lexlib/CatalogueModules.h +++ b/scintilla/lexlib/CatalogueModules.h @@ -51,6 +51,14 @@ public: } } + int LngID(unsigned int index) const noexcept { + if (index < static_cast(lexerCatalogue.size())) { + return lexerCatalogue[index]->language; + } else { + return -1; + } + } + LexerFactoryFunction Factory(unsigned int index) const noexcept { // Works for object lexers but not for function lexers return lexerCatalogue[index]->fnFactory; diff --git a/src/Notepad3.vcxproj b/src/Notepad3.vcxproj index d03cda363..145f901b2 100644 --- a/src/Notepad3.vcxproj +++ b/src/Notepad3.vcxproj @@ -103,7 +103,7 @@ - .\;..\scintilla\include;..\scintilla;%(AdditionalIncludeDirectories) + .\;..\scintilla\include;..\scintilla;..\lexilla\src;%(AdditionalIncludeDirectories) EnableFastChecks EditAndContinue false @@ -169,7 +169,7 @@ - .\;..\scintilla\include;..\scintilla;%(AdditionalIncludeDirectories) + .\;..\scintilla\include;..\scintilla;..\lexilla\src;%(AdditionalIncludeDirectories) EnableFastChecks ProgramDatabase false @@ -234,7 +234,7 @@ - .\;..\scintilla\include;..\scintilla;%(AdditionalIncludeDirectories) + .\;..\scintilla\include;..\scintilla;..\lexilla\src;%(AdditionalIncludeDirectories) true MaxSpeed D_NP3_WIN10_DARK_MODE;_WIN32_WINNT=0x601;WINVER=0x601;NTDDI_VERSION=0x06010000;WIN32;STATIC_BUILD;SCI_LEXER;NDEBUG;%(PreprocessorDefinitions) @@ -306,7 +306,7 @@ - .\;..\scintilla\include;..\scintilla;%(AdditionalIncludeDirectories) + .\;..\scintilla\include;..\scintilla;..\lexilla\src;%(AdditionalIncludeDirectories) true MaxSpeed D_NP3_WIN10_DARK_MODE;_WIN32_WINNT=0x601;WINVER=0x601;NTDDI_VERSION=0x06010000;_WIN64;STATIC_BUILD;SCI_LEXER;NDEBUG;%(PreprocessorDefinitions) diff --git a/src/SciCall.h b/src/SciCall.h index 1acb33984..90d639571 100644 --- a/src/SciCall.h +++ b/src/SciCall.h @@ -244,7 +244,6 @@ DeclareSciCallV0(SelectionDuplicate, SELECTIONDUPLICATE) DeclareSciCallV0(LineTranspose, LINETRANSPOSE) DeclareSciCallV0(MoveSelectedLinesUp, MOVESELECTEDLINESUP) DeclareSciCallV0(MoveSelectedLinesDown, MOVESELECTEDLINESDOWN) -DeclareSciCallR0(GetLexer, GETLEXER, int) DeclareSciCallR2(FindText, FINDTEXT, DocPos, int, flags, struct Sci_TextToFind*, text) // Operations @@ -391,7 +390,10 @@ DeclareSciCallV1(SetVScrollbar, SETVSCROLLBAR, bool, visible) // // Style definition // -DeclareSciCallV1(SetLexer, SETLEXER, int, lexerid) +DeclareSciCallR0(GetLexer, GETLEXER, int) +DeclareSciCallV1(SetLexer, SETLEXER, int, lexerid) // deprecated +DeclareSciCallV01(SetILexer, SETILEXER, void*, lexerPtr) // ILexer5* + DeclareSciCallV0(StyleClearAll, STYLECLEARALL); DeclareSciCallV0(ClearDocumentStyle, CLEARDOCUMENTSTYLE) DeclareSciCallV0(StyleResetDefault, STYLERESETDEFAULT) diff --git a/src/StyleLexers/EditLexer.h b/src/StyleLexers/EditLexer.h index 4a43910a1..c898f6224 100644 --- a/src/StyleLexers/EditLexer.h +++ b/src/StyleLexers/EditLexer.h @@ -1,5 +1,4 @@ -#ifndef _EDIT_LEXER_H_ -#define _EDIT_LEXER_H_ +#pragma once #include "typedefs.h" #include "Scintilla.h" @@ -38,11 +37,11 @@ typedef struct _keywordlist #pragma warning(disable : 4200) // MS's Non-Std: Null-Array in Structure/Union typedef struct _editlexer { - int lexerID; - int resID; - LPCWSTR pszName; - LPCWSTR pszDefExt; - WCHAR szExtensions[BUFZIZE_STYLE_EXTENTIONS]; + int lexerID; + int resID; + LPCWSTR pszName; + LPCWSTR pszDefExt; + WCHAR szExtensions[BUFZIZE_STYLE_EXTENTIONS]; PKEYWORDLIST pKeyWords; EDITSTYLE Styles[]; @@ -138,6 +137,7 @@ extern EDITLEXER lexHTML; // Web Source Code extern EDITLEXER lexXML; // XML Document extern EDITLEXER lexYAML; // YAML + // ----------------------------------------------------------------------------- // common defines // ----------------------------------------------------------------------------- @@ -162,5 +162,3 @@ extern EDITLEXER lexYAML; // YAML "variant wend when while with withevents writeonly xor" // ----------------------------------------------------------------------------- - -#endif // _EDIT_LEXER_H_ diff --git a/src/Styles.c b/src/Styles.c index c4f35b647..a6d3a0299 100644 --- a/src/Styles.c +++ b/src/Styles.c @@ -27,6 +27,8 @@ #include "SciLexer.h" #include "lexers_x/SciXLexer.h" +#include "Lexilla.h" + #include "Edit.h" #include "Dialogs.h" #include "resource.h" @@ -102,7 +104,7 @@ static PEDITLEXER g_pLexArray[NUMLEXERS] = &lexVB, // Visual Basic &lexHTML, // Web Source Code &lexXML, // XML Document - &lexYAML // YAML + &lexYAML, // YAML }; @@ -624,7 +626,7 @@ bool Style_ImportFromFile(const WCHAR* szFile) if (bIsStdIniFile) { IniSectionGetString(Lexer_Section, L"FileNameExtensions", g_pLexArray[iLexer]->pszDefExt, - g_pLexArray[iLexer]->szExtensions, COUNTOF(g_pLexArray[iLexer]->szExtensions)); + g_pLexArray[iLexer]->szExtensions, COUNTOF(g_pLexArray[iLexer]->szExtensions)); } // don't allow empty extensions settings => use default ext if (StrIsEmpty(g_pLexArray[iLexer]->szExtensions)) { @@ -635,9 +637,9 @@ bool Style_ImportFromFile(const WCHAR* szFile) while (g_pLexArray[iLexer]->Styles[i].iStyle != -1) { IniSectionGetString(Lexer_Section, g_pLexArray[iLexer]->Styles[i].pszName, - g_pLexArray[iLexer]->Styles[i].pszDefault, - g_pLexArray[iLexer]->Styles[i].szValue, - COUNTOF(g_pLexArray[iLexer]->Styles[i].szValue)); + g_pLexArray[iLexer]->Styles[i].pszDefault, + g_pLexArray[iLexer]->Styles[i].szValue, + COUNTOF(g_pLexArray[iLexer]->Styles[i].szValue)); ++i; } @@ -1076,8 +1078,14 @@ void Style_SetLexer(HWND hwnd, PEDITLEXER pLexNew) Style_SetUse2ndDefault(pCurrentStandard == &lexStandard2nd); // sync if forced - // Lexer - SciCall_SetLexer(pLexNew->lexerID); + // Set Lexer + if ((pLexNew->lexerID == SCLEX_CONTAINER) || (pLexNew->lexerID == SCLEX_NULL)) { + SciCall_SetLexer(pLexNew->lexerID); + } + else { // ILexer5 via Lexilla + SciCall_SetILexer(CreateLexerByID(pLexNew->lexerID)); + assert(SciCall_GetLexer() == pLexNew->lexerID); + } // Lexer very specific styles Style_SetLexerSpecificProperties(pLexNew->lexerID); @@ -2017,7 +2025,7 @@ PEDITLEXER Style_MatchLexer(LPCWSTR lpszMatch, bool bCheckNames) { if (StrCmpNI(g_pLexArray[iLex]->pszName, lpszMatch, cch) == 0) { - return(g_pLexArray[iLex]); + return (g_pLexArray[iLex]); } } } @@ -2049,7 +2057,7 @@ PEDITLEXER Style_RegExMatchLexer(LPCWSTR lpszFileName) for (int iLex = 0; iLex < COUNTOF(g_pLexArray); ++iLex) { - const WCHAR* p = g_pLexArray[iLex]->szExtensions; + const WCHAR *p = g_pLexArray[iLex]->szExtensions; do { const WCHAR* f = StrChr(p, L'\\'); const WCHAR* e = f; @@ -2346,7 +2354,7 @@ void Style_SetXMLLexer(HWND hwnd) void Style_SetLexerFromID(HWND hwnd,int id) { if (id >= 0 && id < COUNTOF(g_pLexArray)) { - Style_SetLexer(hwnd,g_pLexArray[id]); + Style_SetLexer(hwnd, g_pLexArray[id]); } } @@ -4141,11 +4149,11 @@ INT_PTR CALLBACK Style_CustomizeSchemesDlgProc(HWND hwnd, UINT umsg, WPARAM wPar int cnt = 0; for (int iLexer = 0; iLexer < COUNTOF(g_pLexArray); ++iLexer) { - Style_StylesBackup[cnt++] = StrDup(g_pLexArray[iLexer]->szExtensions); + Style_StylesBackup[cnt++] = StrDup(g_pLexArray[iLexer]->szExtensions); int i = 0; - while (g_pLexArray[iLexer]->Styles[i].iStyle != -1) + while (g_pLexArray[iLexer]->Styles[i].iStyle != -1) { - Style_StylesBackup[cnt++] = StrDup(g_pLexArray[iLexer]->Styles[i].szValue); + Style_StylesBackup[cnt++] = StrDup(g_pLexArray[iLexer]->Styles[i].szValue); ++i; } } @@ -4171,7 +4179,7 @@ INT_PTR CALLBACK Style_CustomizeSchemesDlgProc(HWND hwnd, UINT umsg, WPARAM wPar int found = -1; for (int i = 0; i < COUNTOF(g_pLexArray); ++i) { - if (g_pLexArray[i] == s_pLexCurrent) + if (g_pLexArray[i] == s_pLexCurrent) { found = i; break; @@ -4183,9 +4191,9 @@ INT_PTR CALLBACK Style_CustomizeSchemesDlgProc(HWND hwnd, UINT umsg, WPARAM wPar for (int i = 0; i < COUNTOF(g_pLexArray); i++) { if (i == found) - hCurrentTVLex = Style_AddLexerToTreeView(hwndTV, g_pLexArray[i]); + hCurrentTVLex = Style_AddLexerToTreeView(hwndTV, g_pLexArray[i]); else - Style_AddLexerToTreeView(hwndTV, g_pLexArray[i]); + Style_AddLexerToTreeView(hwndTV, g_pLexArray[i]); } if (!hCurrentTVLex) { @@ -4821,7 +4829,7 @@ INT_PTR CALLBACK Style_CustomizeSchemesDlgProc(HWND hwnd, UINT umsg, WPARAM wPar int cnt = 0; for (int iLexer = 0; iLexer < COUNTOF(g_pLexArray); ++iLexer) { - StringCchCopy(g_pLexArray[iLexer]->szExtensions, COUNTOF(g_pLexArray[iLexer]->szExtensions), Style_StylesBackup[cnt]); + StringCchCopy(g_pLexArray[iLexer]->szExtensions, COUNTOF(g_pLexArray[iLexer]->szExtensions), Style_StylesBackup[cnt]); ++cnt; int i = 0; From a7a4a2556f82d3c816fa68083f7a879ae68a07ec Mon Sep 17 00:00:00 2001 From: Rainer Kottenhoff Date: Fri, 25 Sep 2020 15:22:14 +0200 Subject: [PATCH 5/5] + fix: stop file change notification on deleted files if save is rejected + chg: move home brew lexers to Lexills dir --- lexilla/Lexilla.vcxproj | 17 +++-- lexilla/Lexilla.vcxproj.filters | 15 ++-- .../src}/lexers_x/CharSetX.h | 0 .../src}/lexers_x/LexAHKL.cxx | 0 .../src}/lexers_x/LexCSV.cxx | 0 .../src}/lexers_x/LexTOML.cxx | 0 .../src}/lexers_x/SciX.iface | 0 .../src}/lexers_x/SciXLexer.h | 6 +- .../src}/lexers_x/orig/LexAHK.cxx | 0 .../src}/lexers_x/orig/LexAHKL.cxx | 0 .../src}/lexers_x/orig/styleLexAHK.c | 0 src/Notepad3.c | 70 ++++++++----------- src/Notepad3.h | 2 +- src/StyleLexers/StyleLexers.h | 9 +-- src/Styles.c | 4 +- 15 files changed, 58 insertions(+), 65 deletions(-) rename {scintilla => lexilla/src}/lexers_x/CharSetX.h (100%) rename {scintilla => lexilla/src}/lexers_x/LexAHKL.cxx (100%) rename {scintilla => lexilla/src}/lexers_x/LexCSV.cxx (100%) rename {scintilla => lexilla/src}/lexers_x/LexTOML.cxx (100%) rename {scintilla => lexilla/src}/lexers_x/SciX.iface (100%) rename {scintilla => lexilla/src}/lexers_x/SciXLexer.h (97%) rename {scintilla => lexilla/src}/lexers_x/orig/LexAHK.cxx (100%) rename {scintilla => lexilla/src}/lexers_x/orig/LexAHKL.cxx (100%) rename {scintilla => lexilla/src}/lexers_x/orig/styleLexAHK.c (100%) diff --git a/lexilla/Lexilla.vcxproj b/lexilla/Lexilla.vcxproj index de88ecddb..cf2e95600 100644 --- a/lexilla/Lexilla.vcxproj +++ b/lexilla/Lexilla.vcxproj @@ -19,8 +19,8 @@ - - + + @@ -61,14 +61,17 @@ - - - + + + + + + 16.0 Win32Proj @@ -175,7 +178,7 @@ true stdcpp17 true - ..\scintilla\include;..\scintilla\lexlib;src + ..\scintilla\include;..\scintilla\lexlib;src;ser\lexer_x AnySuitable Speed true @@ -226,7 +229,7 @@ true stdcpp17 true - ..\scintilla\include;..\scintilla\lexlib;src + ..\scintilla\include;..\scintilla\lexlib;src;ser\lexer_x AnySuitable Speed true diff --git a/lexilla/Lexilla.vcxproj.filters b/lexilla/Lexilla.vcxproj.filters index c58f9a161..03bca307e 100644 --- a/lexilla/Lexilla.vcxproj.filters +++ b/lexilla/Lexilla.vcxproj.filters @@ -27,10 +27,10 @@ Header Files - + lexers_x - + lexers_x @@ -149,13 +149,13 @@ lexers - + lexers_x - + lexers_x - + lexers_x @@ -164,4 +164,9 @@ Resource Files + + + lexers_x + + \ No newline at end of file diff --git a/scintilla/lexers_x/CharSetX.h b/lexilla/src/lexers_x/CharSetX.h similarity index 100% rename from scintilla/lexers_x/CharSetX.h rename to lexilla/src/lexers_x/CharSetX.h diff --git a/scintilla/lexers_x/LexAHKL.cxx b/lexilla/src/lexers_x/LexAHKL.cxx similarity index 100% rename from scintilla/lexers_x/LexAHKL.cxx rename to lexilla/src/lexers_x/LexAHKL.cxx diff --git a/scintilla/lexers_x/LexCSV.cxx b/lexilla/src/lexers_x/LexCSV.cxx similarity index 100% rename from scintilla/lexers_x/LexCSV.cxx rename to lexilla/src/lexers_x/LexCSV.cxx diff --git a/scintilla/lexers_x/LexTOML.cxx b/lexilla/src/lexers_x/LexTOML.cxx similarity index 100% rename from scintilla/lexers_x/LexTOML.cxx rename to lexilla/src/lexers_x/LexTOML.cxx diff --git a/scintilla/lexers_x/SciX.iface b/lexilla/src/lexers_x/SciX.iface similarity index 100% rename from scintilla/lexers_x/SciX.iface rename to lexilla/src/lexers_x/SciX.iface diff --git a/scintilla/lexers_x/SciXLexer.h b/lexilla/src/lexers_x/SciXLexer.h similarity index 97% rename from scintilla/lexers_x/SciXLexer.h rename to lexilla/src/lexers_x/SciXLexer.h index a22060f5c..cdbeeeeec 100644 --- a/scintilla/lexers_x/SciXLexer.h +++ b/lexilla/src/lexers_x/SciXLexer.h @@ -1,7 +1,7 @@ // encoding: UTF-8 #pragma once -#ifndef _SCIXLEXER_H_ -#define _SCIXLEXER_H_ + +#include "SciLexer.h" // Scintilla/Lexilla Lexer defines #define SCLEX_AHKL 200 #define SCLEX_TOML 201 @@ -92,5 +92,3 @@ #define SCE_YAML_DATETIME 18 #define SCE_YAML_INDENTED_TEXT 19 - -#endif //_SCIXLEXER_H_ diff --git a/scintilla/lexers_x/orig/LexAHK.cxx b/lexilla/src/lexers_x/orig/LexAHK.cxx similarity index 100% rename from scintilla/lexers_x/orig/LexAHK.cxx rename to lexilla/src/lexers_x/orig/LexAHK.cxx diff --git a/scintilla/lexers_x/orig/LexAHKL.cxx b/lexilla/src/lexers_x/orig/LexAHKL.cxx similarity index 100% rename from scintilla/lexers_x/orig/LexAHKL.cxx rename to lexilla/src/lexers_x/orig/LexAHKL.cxx diff --git a/scintilla/lexers_x/orig/styleLexAHK.c b/lexilla/src/lexers_x/orig/styleLexAHK.c similarity index 100% rename from scintilla/lexers_x/orig/styleLexAHK.c rename to lexilla/src/lexers_x/orig/styleLexAHK.c diff --git a/src/Notepad3.c b/src/Notepad3.c index f70a6f347..a0279603b 100644 --- a/src/Notepad3.c +++ b/src/Notepad3.c @@ -43,7 +43,6 @@ #include "Config/Config.h" #include "DarkMode/DarkMode.h" -#include "SciLexer.h" #include "lexers_x/SciXLexer.h" // ============================================================================ @@ -1431,7 +1430,7 @@ HWND InitInstance(const HINSTANCE hInstance, LPCWSTR pszCmdLine, int nCmdShow) { if (StrIsNotEmpty(s_lpFileArg)) { StringCchCopy(Globals.CurrentFile, COUNTOF(Globals.CurrentFile), s_lpFileArg); - InstallFileWatching(Globals.CurrentFile); + InstallFileWatching(StrIsNotEmpty(Globals.CurrentFile)); } else { StringCchCopy(Globals.CurrentFile, COUNTOF(Globals.CurrentFile), L""); @@ -1477,7 +1476,7 @@ HWND InitInstance(const HINSTANCE hInstance, LPCWSTR pszCmdLine, int nCmdShow) case FWM_MSGBOX: FileWatching.FileWatchingMode = FWM_DONT_CARE; FileWatching.ResetFileWatching = true; - InstallFileWatching(Globals.CurrentFile); + InstallFileWatching(StrIsNotEmpty(Globals.CurrentFile)); break; case FWM_AUTORELOAD: if (!FileWatching.MonitoringLog) { @@ -1486,7 +1485,7 @@ HWND InitInstance(const HINSTANCE hInstance, LPCWSTR pszCmdLine, int nCmdShow) else { FileWatching.FileWatchingMode = FWM_AUTORELOAD; FileWatching.ResetFileWatching = true; - InstallFileWatching(Globals.CurrentFile); + InstallFileWatching(StrIsNotEmpty(Globals.CurrentFile)); } break; case FWM_DONT_CARE: @@ -2769,7 +2768,7 @@ LRESULT MsgEndSession(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) } // Terminate file watching - InstallFileWatching(NULL); + InstallFileWatching(false); DragAcceptFiles(hwnd, true); @@ -3149,7 +3148,7 @@ LRESULT MsgCopyData(HWND hwnd, WPARAM wParam, LPARAM lParam) { FileWatching.FileWatchingMode = FWM_DONT_CARE; FileWatching.ResetFileWatching = true; - InstallFileWatching(Globals.CurrentFile); + InstallFileWatching(StrIsNotEmpty(Globals.CurrentFile)); } else if (params->flagChangeNotify == FWM_AUTORELOAD) { if (!FileWatching.MonitoringLog) { @@ -3158,7 +3157,7 @@ LRESULT MsgCopyData(HWND hwnd, WPARAM wParam, LPARAM lParam) else { FileWatching.FileWatchingMode = FWM_AUTORELOAD; FileWatching.ResetFileWatching = true; - InstallFileWatching(Globals.CurrentFile); + InstallFileWatching(StrIsNotEmpty(Globals.CurrentFile)); } } @@ -3374,16 +3373,23 @@ LRESULT MsgChangeNotify(HWND hwnd, WPARAM wParam, LPARAM lParam) Sci_GotoPosChooseCaret(iCurPos); } } + if (!s_bRunningWatch) { + InstallFileWatching(StrIsNotEmpty(Globals.CurrentFile)); + } } else { INT_PTR const answer = InfoBoxLng(MB_YESNO | MB_ICONWARNING, NULL, IDS_MUI_FILECHANGENOTIFY2); if ((IDOK == answer) || (IDYES == answer)) { FileSave(true, false, false, false, Flags.bPreserveFileModTime); + if (!s_bRunningWatch) { + InstallFileWatching(StrIsNotEmpty(Globals.CurrentFile)); + } + } + else if (!PathIsExistingFile(Globals.CurrentFile)) + { + InstallFileWatching(false); // terminate + SetSaveNeeded(); } - } - - if (!s_bRunningWatch) { - InstallFileWatching(Globals.CurrentFile); } return FALSE; } @@ -5745,7 +5751,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) } EditEnsureSelectionVisible(); - InstallFileWatching(Globals.CurrentFile); // force + InstallFileWatching(StrIsNotEmpty(Globals.CurrentFile)); CheckCmd(GetMenu(Globals.hwndMain), IDM_VIEW_CHASING_DOCTAIL, FileWatching.MonitoringLog); @@ -6016,7 +6022,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) case IDM_VIEW_CHANGENOTIFY: if (ChangeNotifyDlg(hwnd)) { - InstallFileWatching(Globals.CurrentFile); + InstallFileWatching(StrIsNotEmpty(Globals.CurrentFile)); } break; @@ -10089,7 +10095,7 @@ bool FileLoad(bool bDontSave, bool bNew, bool bReload, } FileWatching.FileWatchingMode = Settings.FileWatchingMode; } - InstallFileWatching(NULL); + InstallFileWatching(false); // terminate Flags.bSettingsFileSoftLocked = false; UpdateSaveSettingsCmds(); COND_SHOW_ZOOM_CALLTIP(); @@ -10230,7 +10236,7 @@ bool FileLoad(bool bDontSave, bool bNew, bool bReload, } FileWatching.FileWatchingMode = Settings.FileWatchingMode; } - InstallFileWatching(Globals.CurrentFile); + InstallFileWatching(StrIsNotEmpty(Globals.CurrentFile)); // the .LOG feature ... if (SciCall_GetTextLength() >= 4) { @@ -10658,7 +10664,7 @@ bool FileSave(bool bSaveAlways, bool bAsk, bool bSaveAs, bool bSaveCopy, bool bP } FileWatching.FileWatchingMode = Settings.FileWatchingMode; } - InstallFileWatching(Globals.CurrentFile); + InstallFileWatching(StrIsNotEmpty(Globals.CurrentFile)); } // if current file is settings/config file: ask to start @@ -11374,12 +11380,12 @@ void CancelCallTip() //============================================================================= // -// TerminateFileWatching() +// InstallFileWatching() // -static void TerminateFileWatching() +void InstallFileWatching(const bool bInstall) { - if (s_bRunningWatch) - { + // Terminate previous watching + if (s_bRunningWatch) { KillTimer(NULL, ID_WATCHTIMER); if (s_hChangeHandle) { FindCloseChangeNotification(s_hChangeHandle); @@ -11388,26 +11394,12 @@ static void TerminateFileWatching() s_bRunningWatch = false; s_dwChangeNotifyTime = 0UL; // reset } -} -//============================================================================= -// -// InstallFileWatching() -// -void InstallFileWatching(LPCWSTR lpszFile) -{ - // Terminate - if (StrIsEmpty(lpszFile) || (FileWatching.FileWatchingMode == FWM_DONT_CARE)) + // Install + if (bInstall && (FileWatching.FileWatchingMode != FWM_DONT_CARE)) { - TerminateFileWatching(); - } - else // Install - { - // Terminate previous watching - TerminateFileWatching(); - WCHAR tchDirectory[MAX_PATH] = { L'\0' }; - StringCchCopy(tchDirectory,COUNTOF(tchDirectory),lpszFile); + StringCchCopy(tchDirectory, COUNTOF(tchDirectory), Globals.CurrentFile); PathCchRemoveFileSpec(tchDirectory, COUNTOF(tchDirectory)); // Save data of current file @@ -11487,7 +11479,7 @@ void CALLBACK WatchTimerProc(HWND hwnd,UINT uMsg,UINT_PTR idEvent,DWORD dwTime) && //|| // TODO: OR for read only auto reload without save requester CurrentFileChanged()) { - TerminateFileWatching(); + InstallFileWatching(false); // terminate PostMessage(Globals.hwndMain, WM_CHANGENOTIFY, 0, 0); } break; @@ -11500,7 +11492,7 @@ void CALLBACK WatchTimerProc(HWND hwnd,UINT uMsg,UINT_PTR idEvent,DWORD dwTime) // Check if the changes affect the current file if (CurrentFileChanged()) { // Shutdown current watching and give control to main window - TerminateFileWatching(); + InstallFileWatching(false); // terminate PostMessage(Globals.hwndMain, WM_CHANGENOTIFY, 0, 0); break; // while } diff --git a/src/Notepad3.h b/src/Notepad3.h index 3b649fce7..1d0162c5d 100644 --- a/src/Notepad3.h +++ b/src/Notepad3.h @@ -114,7 +114,7 @@ bool DoElevatedRelaunch(EditFileIOStatus* pFioStatus, bool bAutoSaveOnRelaunch); void SnapToWinInfoPos(HWND hwnd, const WININFO winInfo, SCREEN_MODE mode); void ShowNotifyIcon(HWND hwnd, bool bAdd); void SetNotifyIconTitle(HWND hwnd); -void InstallFileWatching(LPCWSTR lpszFile); +void InstallFileWatching(const bool bInstall); //bool GetDocModified(); void SetSavePoint(); void CALLBACK WatchTimerProc(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime); diff --git a/src/StyleLexers/StyleLexers.h b/src/StyleLexers/StyleLexers.h index 9b4bbff19..9f4623401 100644 --- a/src/StyleLexers/StyleLexers.h +++ b/src/StyleLexers/StyleLexers.h @@ -5,13 +5,10 @@ #include -#include "Scintilla.h" -#include "SciLexer.h" -#include "lexers_x/SciXLexer.h" - #include "resource.h" - -#include "EditLexer.h" +#include "Scintilla.h" +#include "lexers_x/SciXLexer.h" +#include "EditLexer.h" // ---------------------------------------------------------------------------- diff --git a/src/Styles.c b/src/Styles.c index a6d3a0299..1a1f7d9fe 100644 --- a/src/Styles.c +++ b/src/Styles.c @@ -24,10 +24,8 @@ #include #include -#include "SciLexer.h" -#include "lexers_x/SciXLexer.h" - #include "Lexilla.h" +#include "lexers_x/SciXLexer.h" #include "Edit.h" #include "Dialogs.h"