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..cf2e95600 --- /dev/null +++ b/lexilla/Lexilla.vcxproj @@ -0,0 +1,252 @@ + + + + + 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 + MultiThreadedDebug + + + 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;ser\lexer_x + AnySuitable + Speed + true + Fast + StreamingSIMDExtensions2 + MultiThreaded + + + 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 + MultiThreadedDebug + + + 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;ser\lexer_x + AnySuitable + Speed + true + Fast + MultiThreaded + + + 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..03bca307e --- /dev/null +++ b/lexilla/Lexilla.vcxproj.filters @@ -0,0 +1,172 @@ + + + + + {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 + + + + + lexers_x + + + \ No newline at end of file diff --git a/lexilla/src/Lexilla.cxx b/lexilla/src/Lexilla.cxx new file mode 100644 index 000000000..880419d28 --- /dev/null +++ b/lexilla/src/Lexilla.cxx @@ -0,0 +1,365 @@ +// 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 + +#ifdef DLL_EXPORT +#define EXPORT_FUNCTION __declspec(dllexport) +#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" + +#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 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 (void*)catalogueLexilla.Create(i); + } + } + return (void*)nullptr; +} + +} // extern "C" diff --git a/lexilla/src/Lexilla.h b/lexilla/src/Lexilla.h new file mode 100644 index 000000000..b3ba2e791 --- /dev/null +++ b/lexilla/src/Lexilla.h @@ -0,0 +1,24 @@ +// 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 + +#ifdef _cplusplus +extern "C" { +#endif + +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/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/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 99% rename from scintilla/lexers_x/LexAHKL.cxx rename to lexilla/src/lexers_x/LexAHKL.cxx index 9a0057706..669739737 100644 --- a/scintilla/lexers_x/LexAHKL.cxx +++ b/lexilla/src/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/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/scintilla/Scintilla.vcxproj b/scintilla/Scintilla.vcxproj index a3ea16d4e..baa235e93 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;WIN32;_DEBUG;_WINDOWS;_CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES;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;_WIN64;_DEBUG;_WINDOWS;_CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES;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;WIN32;NDEBUG;_WINDOWS;_CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES;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 @@ -233,52 +235,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - true - true - true - true - @@ -332,20 +288,12 @@ - - - - true - true - true - true - diff --git a/scintilla/Scintilla.vcxproj.filters b/scintilla/Scintilla.vcxproj.filters index 397fd87be..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,12 +16,6 @@ {97da2683-9a5a-42f9-8ac6-0e8c54ce61e7} - - {326090d3-060e-4529-9b3e-4be7793fb194} - - - {3e51698b-084e-40cf-8dee-860bd61d7a2c} - {32ffd4ad-2b04-4d07-acff-dad68cf258de} @@ -33,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 @@ -246,48 +147,15 @@ win32 - - lexers - - - lexers - - - lexers - src lexlib - - lexers - - - lexers - - - lexers - - - lexers - src - - lexilla - - - lexers_x - - - lexers_x - - - lexers_x - oniguruma\scintilla @@ -539,15 +407,6 @@ src - - lexilla - - - lexers_x - - - lexers_x - oniguruma\src 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/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/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++; } } 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 77524f928..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" @@ -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); 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/Notepad3.vcxproj b/src/Notepad3.vcxproj index d3dee9943..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 @@ -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 @@ -169,7 +169,7 @@ - .\;..\scintilla\include;..\scintilla;%(AdditionalIncludeDirectories) + .\;..\scintilla\include;..\scintilla;..\lexilla\src;%(AdditionalIncludeDirectories) EnableFastChecks ProgramDatabase false @@ -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 @@ -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) @@ -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 @@ -305,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) @@ -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/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/StyleLexers/StyleLexers.h b/src/StyleLexers/StyleLexers.h index 05025f596..9f4623401 100644 --- a/src/StyleLexers/StyleLexers.h +++ b/src/StyleLexers/StyleLexers.h @@ -5,13 +5,10 @@ #include -#include "Scintilla.h" -#include "SciLexer.h" -#include "../scintilla/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 c4f35b647..1a1f7d9fe 100644 --- a/src/Styles.c +++ b/src/Styles.c @@ -24,7 +24,7 @@ #include #include -#include "SciLexer.h" +#include "Lexilla.h" #include "lexers_x/SciXLexer.h" #include "Edit.h" @@ -102,7 +102,7 @@ static PEDITLEXER g_pLexArray[NUMLEXERS] = &lexVB, // Visual Basic &lexHTML, // Web Source Code &lexXML, // XML Document - &lexYAML // YAML + &lexYAML, // YAML }; @@ -624,7 +624,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 +635,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 +1076,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 +2023,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 +2055,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 +2352,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 +4147,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 +4177,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 +4189,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 +4827,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;