diff --git a/scintilla/License.txt b/scintilla/License.txt index 47c792655..e93ac62f2 100644 --- a/scintilla/License.txt +++ b/scintilla/License.txt @@ -1,6 +1,6 @@ -License for Scintilla and SciTE +License for Lexilla, Scintilla, and SciTE -Copyright 1998-2003 by Neil Hodgson +Copyright 1998-2021 by Neil Hodgson All Rights Reserved diff --git a/scintilla/Scintilla.vcxproj b/scintilla/Scintilla.vcxproj index ef372a4a7..f007bd6f0 100644 --- a/scintilla/Scintilla.vcxproj +++ b/scintilla/Scintilla.vcxproj @@ -433,7 +433,6 @@ - diff --git a/scintilla/Scintilla.vcxproj.filters b/scintilla/Scintilla.vcxproj.filters index 59d07fc3f..a14fbd1e7 100644 --- a/scintilla/Scintilla.vcxproj.filters +++ b/scintilla/Scintilla.vcxproj.filters @@ -239,9 +239,6 @@ src - - src - src diff --git a/scintilla/include/Platform.h b/scintilla/include/Platform.h index 3d4733d07..dd26c5cae 100644 --- a/scintilla/include/Platform.h +++ b/scintilla/include/Platform.h @@ -129,28 +129,29 @@ typedef void *IdlerID; /** * A geometric point class. - * Point is similar to the Win32 POINT and GTK GdkPoint types. + * Point is similar to the Win32 POINT and GTK+ GdkPoint types. */ class Point { public: XYPOSITION x; XYPOSITION y; - constexpr explicit Point(XYPOSITION x_ = 0, XYPOSITION y_ = 0) noexcept : x(x_), y(y_) {} + constexpr explicit Point(XYPOSITION x_=0, XYPOSITION y_=0) noexcept : x(x_), y(y_) { + } static constexpr Point FromInts(int x_, int y_) noexcept { return Point(static_cast(x_), static_cast(y_)); } - bool operator!=(Point other) const noexcept { + constexpr bool operator!=(Point other) const noexcept { return (x != other.x) || (y != other.y); } - Point operator+(Point other) const noexcept { + constexpr Point operator+(Point other) const noexcept { return Point(x + other.x, y + other.y); } - Point operator-(Point other) const noexcept { + constexpr Point operator-(Point other) const noexcept { return Point(x - other.x, y - other.y); } @@ -169,8 +170,9 @@ public: XYPOSITION right; XYPOSITION bottom; - constexpr explicit PRectangle(XYPOSITION left_ = 0, XYPOSITION top_ = 0, XYPOSITION right_ = 0, XYPOSITION bottom_ = 0) noexcept : - left(left_), top(top_), right(right_), bottom(bottom_) {} + constexpr explicit PRectangle(XYPOSITION left_=0, XYPOSITION top_=0, XYPOSITION right_=0, XYPOSITION bottom_ = 0) noexcept : + left(left_), top(top_), right(right_), bottom(bottom_) { + } static constexpr PRectangle FromInts(int left_, int top_, int right_, int bottom_) noexcept { return PRectangle(static_cast(left_), static_cast(top_), @@ -179,24 +181,24 @@ public: // Other automatically defined methods (assignment, copy constructor, destructor) are fine - bool operator==(const PRectangle &rc) const noexcept { + constexpr bool operator==(const PRectangle &rc) const noexcept { return (rc.left == left) && (rc.right == right) && (rc.top == top) && (rc.bottom == bottom); } - bool Contains(Point pt) const noexcept { + constexpr bool Contains(Point pt) const noexcept { return (pt.x >= left) && (pt.x <= right) && (pt.y >= top) && (pt.y <= bottom); } - bool ContainsWholePixel(Point pt) const noexcept { + constexpr bool ContainsWholePixel(Point pt) const noexcept { // Does the rectangle contain all of the pixel to left/below the point - return (pt.x >= left) && ((pt.x + 1) <= right) && - (pt.y >= top) && ((pt.y + 1) <= bottom); + return (pt.x >= left) && ((pt.x+1) <= right) && + (pt.y >= top) && ((pt.y+1) <= bottom); } - bool Contains(PRectangle rc) const noexcept { + constexpr bool Contains(PRectangle rc) const noexcept { return (rc.left >= left) && (rc.right <= right) && (rc.top >= top) && (rc.bottom <= bottom); } - bool Intersects(PRectangle other) const noexcept { + constexpr bool Intersects(PRectangle other) const noexcept { return (right > other.left) && (left < other.right) && (bottom > other.top) && (top < other.bottom); } @@ -232,20 +234,22 @@ public: /** * Holds an RGB colour with 8 bits for each component. */ -constexpr float componentMaximum = 255.0F; +constexpr const float componentMaximum = 255.0f; class ColourDesired { - unsigned int co; + int co; public: - constexpr explicit ColourDesired(unsigned int co_ = 0) noexcept : co(co_) {} + constexpr explicit ColourDesired(int co_=0) noexcept : co(co_) { + } - ColourDesired(unsigned int red, unsigned int green, unsigned int blue) noexcept : - co(red | (green << 8) | (blue << 16)) {} + constexpr ColourDesired(unsigned int red, unsigned int green, unsigned int blue) noexcept : + co(red | (green << 8) | (blue << 16)) { + } constexpr bool operator==(const ColourDesired &other) const noexcept { return co == other.co; } - constexpr unsigned int AsInteger() const noexcept { + constexpr int AsInteger() const noexcept { return co; } @@ -277,15 +281,20 @@ public: */ class ColourAlpha : public ColourDesired { public: - constexpr explicit ColourAlpha(unsigned int co_ = 0) noexcept : ColourDesired(co_) {} + constexpr explicit ColourAlpha(int co_ = 0) noexcept : ColourDesired(co_) { + } - ColourAlpha(unsigned int red, unsigned int green, unsigned int blue) noexcept : - ColourDesired(red | (green << 8) | (blue << 16)) {} - ColourAlpha(unsigned int red, unsigned int green, unsigned int blue, unsigned int alpha) noexcept : - ColourDesired(red | (green << 8) | (blue << 16) | (alpha << 24)) {} + constexpr ColourAlpha(unsigned int red, unsigned int green, unsigned int blue) noexcept : + ColourDesired(red | (green << 8) | (blue << 16)) { + } - ColourAlpha(ColourDesired cd, unsigned int alpha) noexcept : - ColourDesired(cd.AsInteger() | (alpha << 24)) {} + constexpr ColourAlpha(unsigned int red, unsigned int green, unsigned int blue, unsigned int alpha) noexcept : + ColourDesired(red | (green << 8) | (blue << 16) | (alpha << 24)) { + } + + constexpr ColourAlpha(ColourDesired cd, unsigned int alpha) noexcept : + ColourDesired(cd.AsInteger() | (alpha << 24)) { + } constexpr ColourDesired GetColour() const noexcept { return ColourDesired(AsInteger() & 0xffffff); @@ -299,7 +308,7 @@ public: return GetAlpha() / componentMaximum; } - ColourAlpha MixedWith(ColourAlpha other) const noexcept { + constexpr ColourAlpha MixedWith(ColourAlpha other) const noexcept { const unsigned int red = (GetRed() + other.GetRed()) / 2; const unsigned int green = (GetGreen() + other.GetGreen()) / 2; const unsigned int blue = (GetBlue() + other.GetBlue()) / 2; @@ -316,7 +325,8 @@ public: float position; ColourAlpha colour; ColourStop(float position_, ColourAlpha colour_) noexcept : - position(position_), colour(colour_) {} + position(position_), colour(colour_) { + } }; /** diff --git a/scintilla/include/Sci_Position.h b/scintilla/include/Sci_Position.h index 9a08e6b88..0ebdf5983 100644 --- a/scintilla/include/Sci_Position.h +++ b/scintilla/include/Sci_Position.h @@ -24,7 +24,6 @@ typedef size_t Sci_PositionU; // For Sci_CharacterRange which is defined as long to be compatible with Win32 CHARRANGE typedef long Sci_PositionCR; - #ifdef _WIN32 #define SCI_METHOD __stdcall #else diff --git a/scintilla/include/Scintilla.iface b/scintilla/include/Scintilla.iface index 84ea8245b..6d63aaf5d 100644 --- a/scintilla/include/Scintilla.iface +++ b/scintilla/include/Scintilla.iface @@ -1658,7 +1658,6 @@ fun void LinesSplit=2289(int pixelWidth,) # Set one of the colours used as a chequerboard pattern in the fold margin fun void SetFoldMarginColour=2290(bool useSetting, colour back) - # Set the other colour used as a chequerboard pattern in the fold margin fun void SetFoldMarginHiColour=2291(bool useSetting, colour fore) @@ -3133,7 +3132,6 @@ val SC_CHARACTERSOURCE_TENTATIVE_INPUT=1 # IME (either inline or windowed mode) full composited string. val SC_CHARACTERSOURCE_IME_RESULT=2 - # Events evt void StyleNeeded=2000(int position) diff --git a/scintilla/scripts/HFacer.py b/scintilla/scripts/HFacer.py index d32054ec9..0955cdaf1 100644 --- a/scintilla/scripts/HFacer.py +++ b/scintilla/scripts/HFacer.py @@ -9,15 +9,6 @@ import Face from FileGenerator import UpdateFile, Generate, Regenerate, UpdateLineInFile, lineEnd -def printLexHFile(f): - out = [] - for name in f.order: - v = f.features[name] - if v["FeatureType"] in ["val"]: - if "SCE_" in name or "SCLEX_" in name: - out.append("#define " + name + " " + v["Value"]) - return out - def printHFile(f): out = [] previousCategory = "" @@ -36,8 +27,7 @@ def printHFile(f): featureDefineName = "SCN_" + name.upper() out.append("#define " + featureDefineName + " " + v["Value"]) elif v["FeatureType"] in ["val"]: - if not ("SCE_" in name or "SCLEX_" in name): - out.append("#define " + name + " " + v["Value"]) + out.append("#define " + name + " " + v["Value"]) if anyProvisional: out.append("#endif") return out @@ -46,7 +36,6 @@ def RegenerateAll(root, showMaxID): f = Face.Face() f.ReadFromFile(root / "include/Scintilla.iface") Regenerate(root / "include/Scintilla.h", "/* ", printHFile(f)) - Regenerate(root / "include/SciLexer.h", "/* ", printLexHFile(f)) if showMaxID: valueSet = set(int(x) for x in f.values if int(x) < 3000) maximumID = max(valueSet) diff --git a/scintilla/scripts/HeaderCheck.py b/scintilla/scripts/HeaderCheck.py index 29dc4fba3..1349c3b20 100644 --- a/scintilla/scripts/HeaderCheck.py +++ b/scintilla/scripts/HeaderCheck.py @@ -1,23 +1,9 @@ #!/usr/bin/env python3 # Script to check that headers are in a consistent order -# Canonical header order is defined in scripts/HeaderOrder.txt +# Canonical header order is defined in a file, normally scripts/HeaderOrder.txt # Requires Python 3.6 or later -import pathlib - -patterns = [ - "include/*.h", - "src/*.cxx", - "lexlib/*.cxx", - "lexers/*.cxx", - "win32/*.cxx", - "gtk/*.cxx", - "cocoa/*.mm", - "cocoa/*.h", - "test/unit/*.cxx", - "lexilla/src/*.cxx", - "lexilla/test/*.cxx", -] +import pathlib, sys def IsHeader(x): return x.strip().startswith("#") and \ @@ -28,32 +14,41 @@ def HeaderFromIncludeLine(s): #\s*#\s*(include|import)\s+\S+\s* return s.strip()[1:].strip()[7:].strip() -def ExtractHeaders(filename): - with filename.open(encoding="cp437") as infile: +def ExtractHeaders(file): + with file.open(encoding="cp437") as infile: return [HeaderFromIncludeLine(l) for l in infile if IsHeader(l)] -def ExcludeName(name): - # LexCaml adds system headers in #if to be an external lexer - # moc_ files are generated by Qt and follow its rules - return "LexCaml" in name or "moc_" in name +def ExtractWithPrefix(file, prefix): + with file.open(encoding="cp437") as infile: + return [l.strip()[len(prefix):] for l in infile if l.startswith(prefix)] + +def ExcludeName(name, excludes): + return any(exclude in name for exclude in excludes) def SortLike(incs, order): return sorted(incs, key = lambda i: order.index(i)) -def CheckFiles(root): - # Find all the lexer source code files +basePrefix = "//base:" +sourcePrefix = "//source:" +excludePrefix = "//exclude:" + +def CheckFiles(headerOrderTxt): + headerOrderFile = pathlib.Path(headerOrderTxt).resolve() + bases = ExtractWithPrefix(headerOrderFile, basePrefix) + base = bases[0] if len(bases) > 0 else ".." + orderDirectory = headerOrderFile.parent + root = (orderDirectory / base).resolve() + + # Find all the source code files + patterns = ExtractWithPrefix(headerOrderFile, sourcePrefix) + excludes = ExtractWithPrefix(headerOrderFile, excludePrefix) + filePaths = [] for p in patterns: filePaths += root.glob(p) - # The Qt platform code interleaves system and Scintilla headers - #~ filePaths += root.glob("qt/ScintillaEditBase/*.cpp") - #~ filePaths += root.glob("qt/ScintillaEdit/*.cpp") - #~ print(filePaths) - scriptDirectory = root / "scripts" - headerOrderFile = scriptDirectory / "HeaderOrder.txt" headerOrder = ExtractHeaders(headerOrderFile) originalOrder = headerOrder[:] - orderedPaths = [p for p in sorted(filePaths) if not ExcludeName(str(p))] + orderedPaths = [p for p in sorted(filePaths) if not ExcludeName(str(p), excludes)] allIncs = set() for f in orderedPaths: print(" File ", f.relative_to(root)) @@ -105,7 +100,7 @@ def CheckFiles(root): if headerOrder != originalOrder: newIncludes = set(headerOrder) - set(originalOrder) - headerOrderNew = scriptDirectory / "NewOrder.txt" + headerOrderNew = orderDirectory / "NewOrder.txt" print(f"{headerOrderFile}:1: changed to {headerOrderNew}") print(f" Added {', '.join(newIncludes)}.") with headerOrderNew.open("w") as headerOut: @@ -117,4 +112,7 @@ def CheckFiles(root): print("In HeaderOrder.txt but not used") print("\n".join(unused)) -CheckFiles(pathlib.Path(__file__).resolve().parent.parent) +if len(sys.argv) > 1: + CheckFiles(sys.argv[1]) +else: + CheckFiles("HeaderOrder.txt") diff --git a/scintilla/scripts/HeaderOrder.txt b/scintilla/scripts/HeaderOrder.txt index 1f61d5440..23aaad9f8 100644 --- a/scintilla/scripts/HeaderOrder.txt +++ b/scintilla/scripts/HeaderOrder.txt @@ -2,15 +2,26 @@ // All platform headers should be included before Scintilla headers // and each of these groups are then divided into directory groups. +// Base of the repository relative to this file + +//base:.. + +// File patterns to check: +//source:include/*.h +//source:src/*.cxx +//source:lexlib/*.cxx +//source:lexers/*.cxx +//source:win32/*.cxx +//source:gtk/*.cxx +//source:cocoa/*.mm +//source:cocoa/*.h +//source:test/unit/*.cxx +//source:lexilla/src/*.cxx +//source:lexilla/test/*.cxx + // C standard library #include -#include #include -#include -#include -#include -#include -#include // C++ wrappers of C standard library #include @@ -18,7 +29,6 @@ #include #include #include -#include #include #include #include @@ -28,12 +38,10 @@ // C++ standard library #include #include -#include #include #include #include #include -#include #include #include #include @@ -44,9 +52,7 @@ #include #include #include -#include #include -#include // POSIX #include @@ -91,30 +97,11 @@ #include "Scintilla.h" #include "ScintillaWidget.h" -#include "SciLexer.h" - // lexlib -#include "StringCopy.h" -#include "PropSetSimple.h" -#include "WordList.h" -#include "LexAccessor.h" -#include "Accessor.h" -#include "StyleContext.h" #include "CharacterSet.h" #include "CharacterCategory.h" -#include "LexerModule.h" -#include "CatalogueModules.h" -#include "OptionSet.h" -#include "SparseState.h" -#include "SubStyles.h" -#include "DefaultLexer.h" -#include "LexerBase.h" -#include "LexerSimple.h" -#include "LexerNoExceptions.h" // src -#include "Catalogue.h" - #include "Position.h" #include "IntegerRectangle.h" #include "UniqueString.h" @@ -152,12 +139,6 @@ #include "AutoComplete.h" #include "ScintillaBase.h" -#include "ExternalLexer.h" - -#include "Lexilla.h" -#include "TestDocument.h" -#include "LexillaAccess.h" - // Platform-specific headers // win32 diff --git a/scintilla/scripts/LexGen.py b/scintilla/scripts/LexGen.py index 7927de624..c638e9878 100644 --- a/scintilla/scripts/LexGen.py +++ b/scintilla/scripts/LexGen.py @@ -54,11 +54,6 @@ def UpdateVersionNumbers(sci, root): cocoa = root / "cocoa" - UpdateLineInPlistFile(cocoa / "ScintillaFramework/Info.plist", - "CFBundleVersion", sci.versionDotted) - UpdateLineInPlistFile(cocoa / "ScintillaFramework/Info.plist", - "CFBundleShortVersionString", sci.versionDotted) - UpdateLineInPlistFile(cocoa / "Scintilla" / "Info.plist", "CFBundleShortVersionString", sci.versionDotted) ReplaceREInFile(cocoa / "Scintilla"/ "Scintilla.xcodeproj" / "project.pbxproj", @@ -72,61 +67,6 @@ def uid24(): def ciLexerKey(a): return a.split()[2].lower() -""" - 11F35FDB12AEFAF100F0236D /* LexA68k.cxx in Sources */ = {isa = PBXBuildFile; fileRef = 11F35FDA12AEFAF100F0236D /* LexA68k.cxx */; }; - 11F35FDA12AEFAF100F0236D /* LexA68k.cxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = LexA68k.cxx; path = ../../lexers/LexA68k.cxx; sourceTree = SOURCE_ROOT; }; - 11F35FDA12AEFAF100F0236D /* LexA68k.cxx */, - 11F35FDB12AEFAF100F0236D /* LexA68k.cxx in Sources */, -""" -def RegenerateXcodeProject(path, lexers, lexerReferences): - # Build 4 blocks for insertion: - # Each markers contains a unique section start, an optional wait string, and a section end - - markersPBXBuildFile = ["Begin PBXBuildFile section", "", "End PBXBuildFile section"] - sectionPBXBuildFile = [] - - markersPBXFileReference = ["Begin PBXFileReference section", "", "End PBXFileReference section"] - sectionPBXFileReference = [] - - markersLexers = ["/* Lexers */ =", "children", ");"] - sectionLexers = [] - - markersPBXSourcesBuildPhase = ["Begin PBXSourcesBuildPhase section", "files", ");"] - sectionPBXSourcesBuildPhase = [] - - for lexer in lexers: - if lexer not in lexerReferences: - uid1 = uid24() - uid2 = uid24() - print("Lexer", lexer, "is not in Xcode project. Use IDs", uid1, uid2) - lexerReferences[lexer] = [uid1, uid2] - linePBXBuildFile = "\t\t{} /* {}.cxx in Sources */ = {{isa = PBXBuildFile; fileRef = {} /* {}.cxx */; }};".format(uid1, lexer, uid2, lexer) - linePBXFileReference = "\t\t{} /* {}.cxx */ = {{isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = {}.cxx; path = ../../lexers/{}.cxx; sourceTree = SOURCE_ROOT; }};".format(uid2, lexer, lexer, lexer) - lineLexers = "\t\t\t\t{} /* {}.cxx */,".format(uid2, lexer) - linePBXSourcesBuildPhase = "\t\t\t\t{} /* {}.cxx in Sources */,".format(uid1, lexer) - sectionPBXBuildFile.append(linePBXBuildFile) - sectionPBXFileReference.append(linePBXFileReference) - sectionLexers.append(lineLexers) - sectionPBXSourcesBuildPhase.append(linePBXSourcesBuildPhase) - - lines = ReadFileAsList(path) - - sli = FindSectionInList(lines, markersPBXBuildFile) - lines[sli.stop:sli.stop] = sectionPBXBuildFile - - sli = FindSectionInList(lines, markersPBXFileReference) - lines[sli.stop:sli.stop] = sectionPBXFileReference - - sli = FindSectionInList(lines, markersLexers) - # This section is shown in the project outline so sort it to make it easier to navigate. - allLexers = sorted(lines[sli.start:sli.stop] + sectionLexers, key=ciLexerKey) - lines[sli] = allLexers - - sli = FindSectionInList(lines, markersPBXSourcesBuildPhase) - lines[sli.stop:sli.stop] = sectionPBXSourcesBuildPhase - - UpdateFileFromLines(path, lines, "\n") - def RegenerateAll(rootDirectory): root = pathlib.Path(rootDirectory) @@ -135,7 +75,6 @@ def RegenerateAll(rootDirectory): sci = ScintillaData.ScintillaData(scintillaBase) - Regenerate(scintillaBase / "src/Catalogue.cxx", "//", sci.lexerModules) Regenerate(scintillaBase / "win32/scintilla.mak", "#", sci.lexFiles) startDir = os.getcwd() @@ -145,9 +84,6 @@ def RegenerateAll(rootDirectory): gtk.DepGen.Generate() os.chdir(startDir) - RegenerateXcodeProject(root / "cocoa/ScintillaFramework/ScintillaFramework.xcodeproj/project.pbxproj", - sci.lexFiles, sci.lexersXcode) - UpdateVersionNumbers(sci, root) HFacer.RegenerateAll(root, False) diff --git a/scintilla/scripts/ScintillaData.py b/scintilla/scripts/ScintillaData.py index 1d9537d03..7937c321e 100644 --- a/scintilla/scripts/ScintillaData.py +++ b/scintilla/scripts/ScintillaData.py @@ -233,8 +233,6 @@ class ScintillaData: self.lexerProperties = list(lexerProperties) SortListInsensitive(self.lexerProperties) - self.lexersXcode = FindLexersInXcode(scintillaRoot / - "cocoa/ScintillaFramework/ScintillaFramework.xcodeproj/project.pbxproj") self.credits = FindCredits(scintillaRoot / "doc" / "ScintillaHistory.html") def printWrapped(text): @@ -247,8 +245,6 @@ if __name__=="__main__": sci.dateModified, sci.yearModified, sci.mdyModified, sci.dmyModified, sci.myModified)) printWrapped(str(len(sci.lexFiles)) + " lexer files: " + ", ".join(sci.lexFiles)) printWrapped(str(len(sci.lexerModules)) + " lexer modules: " + ", ".join(sci.lexerModules)) - #~ printWrapped(str(len(sci.lexersXcode)) + " Xcode lexer references: " + ", ".join( - #~ [lex+":"+uids[0]+","+uids[1] for lex, uids in sci.lexersXcode.items()])) print("Lexer name to ID:") lexNames = sorted(sci.sclexFromName.keys()) for lexName in lexNames: diff --git a/scintilla/src/Catalogue.cxx b/scintilla/src/Catalogue.cxx deleted file mode 100644 index ae63389cb..000000000 --- a/scintilla/src/Catalogue.cxx +++ /dev/null @@ -1,207 +0,0 @@ -// Scintilla source code edit control -/** @file Catalogue.cxx - ** Lexer infrastructure. - ** Contains a list of LexerModules which can be searched to find a module appropriate for a - ** particular language. - **/ -// Copyright 1998-2002 by Neil Hodgson -// The License.txt file describes the conditions under which this software may be distributed. - -#include -#include -#include - -#include -#include - -#include "ILexer.h" -#include "Scintilla.h" -#include "SciLexer.h" - -#include "LexerModule.h" -#include "CatalogueModules.h" -#include "Catalogue.h" - -using namespace Scintilla; - -namespace { - -CatalogueModules catalogueDefault; - -} - -const LexerModule *Catalogue::Find(int language) { - return catalogueDefault.Find(language); -} - -const LexerModule *Catalogue::Find(const char *languageName) noexcept { - return catalogueDefault.Find(languageName); -} - -void Catalogue::AddLexerModule(LexerModule *plm) { - catalogueDefault.AddLexerModule(plm); -} - -// To add or remove a lexer, add or remove its file and run LexGen.py. - -// 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; - if (initialised) - return 0; - initialised = 1; - -#if !defined(SCI_EMPTYCATALOGUE) - -// Shorten the code that declares a lexer and ensures it is linked in by calling a method. -#define LINK_LEXER(lexer) extern LexerModule lexer; catalogueDefault.AddLexerModule(&lexer); - -//++Autogenerated -- run scripts/LexGen.py to regenerate -//**\(\tLINK_LEXER(\*);\n\) - //LINK_LEXER(lmA68k); - //LINK_LEXER(lmAbaqus); - //LINK_LEXER(lmAda); - //LINK_LEXER(lmAPDL); - //LINK_LEXER(lmAs); - LINK_LEXER(lmAsm); - //LINK_LEXER(lmAsn1); - //LINK_LEXER(lmASY); - LINK_LEXER(lmAU3); - //LINK_LEXER(lmAVE); - LINK_LEXER(lmAVS); - //LINK_LEXER(lmBaan); - LINK_LEXER(lmBash); - LINK_LEXER(lmBatch); - //LINK_LEXER(lmBibTeX); - //LINK_LEXER(lmBlitzBasic); - //LINK_LEXER(lmBullant); - //LINK_LEXER(lmCaml); - //LINK_LEXER(lmCIL); - //LINK_LEXER(lmClw); - //LINK_LEXER(lmClwNoCase); - LINK_LEXER(lmCmake); - //LINK_LEXER(lmCOBOL); - LINK_LEXER(lmCoffeeScript); - LINK_LEXER(lmConf); - LINK_LEXER(lmCPP); - LINK_LEXER(lmCPPNoCase); - //LINK_LEXER(lmCsound); - LINK_LEXER(lmCss); - LINK_LEXER(lmD); - //LINK_LEXER(lmDataflex); - LINK_LEXER(lmDiff); - //LINK_LEXER(lmDMAP); - //LINK_LEXER(lmDMIS); - //LINK_LEXER(lmECL); - //LINK_LEXER(lmEDIFACT); - //LINK_LEXER(lmEiffel); - //LINK_LEXER(lmEiffelkw); - //LINK_LEXER(lmErlang); - //LINK_LEXER(lmErrorList); - //LINK_LEXER(lmESCRIPT); - //LINK_LEXER(lmF77); - //LINK_LEXER(lmFlagShip); - //LINK_LEXER(lmForth); - //LINK_LEXER(lmFortran); - //LINK_LEXER(lmFreeBasic); - //LINK_LEXER(lmGAP); - //LINK_LEXER(lmGui4Cli); - //LINK_LEXER(lmHaskell); - //LINK_LEXER(lmHollywood); - LINK_LEXER(lmHTML); - //LINK_LEXER(lmIHex); - //LINK_LEXER(lmIndent); - LINK_LEXER(lmInno); - LINK_LEXER(lmJSON); - //LINK_LEXER(lmKix); - //LINK_LEXER(lmKVIrc); - LINK_LEXER(lmLatex); - //LINK_LEXER(lmLISP); - //LINK_LEXER(lmLiterateHaskell); - //LINK_LEXER(lmLot); - //LINK_LEXER(lmLout); - LINK_LEXER(lmLua); - //LINK_LEXER(lmMagikSF); - LINK_LEXER(lmMake); - LINK_LEXER(lmMarkdown); - LINK_LEXER(lmMatlab); - //LINK_LEXER(lmMaxima); - //LINK_LEXER(lmMETAPOST); - //LINK_LEXER(lmMMIXAL); - //LINK_LEXER(lmModula); - //LINK_LEXER(lmMSSQL); - //LINK_LEXER(lmMySQL); - LINK_LEXER(lmNim); - //LINK_LEXER(lmNimrod); - //LINK_LEXER(lmNncrontab); - LINK_LEXER(lmNsis); - LINK_LEXER(lmNull); - //LINK_LEXER(lmOctave); - //LINK_LEXER(lmOpal); - //LINK_LEXER(lmOScript); - LINK_LEXER(lmPascal); - //LINK_LEXER(lmPB); - LINK_LEXER(lmPerl); - //LINK_LEXER(lmPHPSCRIPT); - //LINK_LEXER(lmPLM); - //LINK_LEXER(lmPO); - //LINK_LEXER(lmPOV); - //LINK_LEXER(lmPowerPro); - LINK_LEXER(lmPowerShell); - //LINK_LEXER(lmProgress); - LINK_LEXER(lmProps); - //LINK_LEXER(lmPS); - //LINK_LEXER(lmPureBasic); - LINK_LEXER(lmPython); - LINK_LEXER(lmR); - //LINK_LEXER(lmRaku); - //LINK_LEXER(lmREBOL); - LINK_LEXER(lmRegistry); - LINK_LEXER(lmRuby); - LINK_LEXER(lmRust); - //LINK_LEXER(lmSAS); - //LINK_LEXER(lmScriptol); - //LINK_LEXER(lmSmalltalk); - //LINK_LEXER(lmSML); - //LINK_LEXER(lmSorc); - //LINK_LEXER(lmSpecman); - //LINK_LEXER(lmSpice); - LINK_LEXER(lmSQL); - //LINK_LEXER(lmSrec); - //LINK_LEXER(lmStata); - //LINK_LEXER(lmSTTXT); - //LINK_LEXER(lmTACL); - //LINK_LEXER(lmTADS3); - //LINK_LEXER(lmTAL); - LINK_LEXER(lmTCL); - //LINK_LEXER(lmTCMD); - //LINK_LEXER(lmTEHex); - //LINK_LEXER(lmTeX); - //LINK_LEXER(lmTxt2tags); - LINK_LEXER(lmVB); - LINK_LEXER(lmVBScript); - //LINK_LEXER(lmVerilog); - LINK_LEXER(lmVHDL); - //LINK_LEXER(lmVisualProlog); - //LINK_LEXER(lmX12); - LINK_LEXER(lmXML); - LINK_LEXER(lmYAML); - -//--Autogenerated -- end of automatically generated section - - // EXTERNAL LEXERS - LINK_LEXER(lmAHKL); - LINK_LEXER(lmCSV); - LINK_LEXER(lmDart); - LINK_LEXER(lmKotlin); - LINK_LEXER(lmTOML); - -#endif // SCI_EMPTYCATALOGUE - - return 1; -} -#endif // SCI_LEXER - diff --git a/scintilla/src/Catalogue.h b/scintilla/src/Catalogue.h deleted file mode 100644 index 05a1f1d29..000000000 --- a/scintilla/src/Catalogue.h +++ /dev/null @@ -1,24 +0,0 @@ -// Scintilla source code edit control -/** @file Catalogue.h - ** Lexer infrastructure. - ** Contains a list of LexerModules which can be searched to find a module appropriate for a - ** particular language. - **/ -// Copyright 1998-2010 by Neil Hodgson -// The License.txt file describes the conditions under which this software may be distributed. - -#ifndef CATALOGUE_H -#define CATALOGUE_H - -namespace Scintilla { - -class Catalogue { -public: - static const LexerModule *Find(int language); - static const LexerModule *Find(const char *languageName) noexcept; - static void AddLexerModule(LexerModule *plm); -}; - -} - -#endif diff --git a/scintilla/src/EditView.cxx b/scintilla/src/EditView.cxx index 2c43318e3..174e1a0e1 100644 --- a/scintilla/src/EditView.cxx +++ b/scintilla/src/EditView.cxx @@ -816,7 +816,7 @@ Sci::Position EditView::StartEndDisplayLine(Surface *surface, const EditModel &m if (subLine == ll->lines - 1) posRet = ll->numCharsBeforeEOL + posLineStart; else - posRet = ll->LineStart(subLine + 1) + posLineStart - 1; + posRet = model.pdoc->MovePositionOutsideChar(ll->LineStart(subLine + 1) + posLineStart - 1, -1, false); } } } diff --git a/scintilla/src/ExternalLexer.cxx b/scintilla/src/ExternalLexer.cxx deleted file mode 100644 index f30df308d..000000000 --- a/scintilla/src/ExternalLexer.cxx +++ /dev/null @@ -1,220 +0,0 @@ -// Scintilla source code edit control -/** @file ExternalLexer.cxx - ** Support external lexers in DLLs or shared libraries. - **/ -// Copyright 2001 Simon Steele , portions copyright Neil Hodgson. -// The License.txt file describes the conditions under which this software may be distributed. - -#include -#include -#include - -#include -#include -#include -#include -#include - -#include "Platform.h" - -#include "ILexer.h" -#include "Scintilla.h" -#include "SciLexer.h" - -#include "LexerModule.h" -#include "Catalogue.h" -#include "ExternalLexer.h" - -using namespace Scintilla; - -#if PLAT_WIN -#define EXT_LEXER_DECL __stdcall -#else -#define EXT_LEXER_DECL -#endif - -namespace { - -int nextLanguage = SCLEX_AUTOMATIC + 1; - -using GetLexerCountFn = int (EXT_LEXER_DECL *)(); -using GetLexerNameFn = void (EXT_LEXER_DECL *)(unsigned int Index, char *name, int buflength); -using GetLexerFactoryFunction = LexerFactoryFunction(EXT_LEXER_DECL *)(unsigned int Index); - -/// Generic function to convert from a void* to a function pointer. -/// This avoids undefined and conditionally defined behaviour. -template -T FunctionPointer(void *function) noexcept { - static_assert(sizeof(T) == sizeof(function)); - T fp; - memcpy(&fp, &function, sizeof(T)); - return fp; -} - -/// Sub-class of LexerModule to use an external lexer. -class ExternalLexerModule : public LexerModule { -protected: - GetLexerFactoryFunction fneFactory; - std::string name; -public: - ExternalLexerModule(int language_, LexerFunction fnLexer_, - const char *languageName_=nullptr, LexerFunction fnFolder_=nullptr) : - LexerModule(language_, fnLexer_, nullptr, fnFolder_), - fneFactory(nullptr), name(languageName_){ - languageName = name.c_str(); - } - void SetExternal(GetLexerFactoryFunction fFactory, int index) noexcept; -}; - -/// LexerLibrary exists for every External Lexer DLL, contains ExternalLexerModules. -class LexerLibrary { - std::unique_ptr lib; - std::vector> modules; -public: - explicit LexerLibrary(const char *moduleName_); - ~LexerLibrary(); - - std::string moduleName; -}; - -/// LexerManager manages external lexers, contains LexerLibrarys. -class LexerManager { -public: - ~LexerManager(); - - static LexerManager *GetInstance(); - static void DeleteInstance() noexcept; - - void Load(const char *path); - void Clear() noexcept; - -private: - LexerManager(); - static std::unique_ptr theInstance; - std::vector> libraries; -}; - -class LMMinder { -public: - ~LMMinder(); -}; - -std::unique_ptr LexerManager::theInstance; - -//------------------------------------------ -// -// ExternalLexerModule -// -//------------------------------------------ - -void ExternalLexerModule::SetExternal(GetLexerFactoryFunction fFactory, int index) noexcept { - fneFactory = fFactory; - fnFactory = fFactory(index); -} - -//------------------------------------------ -// -// LexerLibrary -// -//------------------------------------------ - -LexerLibrary::LexerLibrary(const char *moduleName_) { - // Load the DLL - lib.reset(DynamicLibrary::Load(moduleName_)); - if (lib->IsValid()) { - moduleName = moduleName_; - GetLexerCountFn GetLexerCount = FunctionPointer(lib->FindFunction("GetLexerCount")); - - if (GetLexerCount) { - // Find functions in the DLL - GetLexerNameFn GetLexerName = FunctionPointer(lib->FindFunction("GetLexerName")); - GetLexerFactoryFunction fnFactory = FunctionPointer(lib->FindFunction("GetLexerFactory")); - - if (!GetLexerName || !fnFactory) { - return; - } - - const int nl = GetLexerCount(); - - for (int i = 0; i < nl; i++) { - // Assign a buffer for the lexer name. - char lexname[100] = ""; - GetLexerName(i, lexname, sizeof(lexname)); - ExternalLexerModule *lex = new ExternalLexerModule(nextLanguage, nullptr, lexname, nullptr); - nextLanguage++; - - // This is storing a second reference to lex in the Catalogue as well as in modules. - // TODO: Should use std::shared_ptr or similar to ensure allocation safety. - Catalogue::AddLexerModule(lex); - - // Remember ExternalLexerModule so we don't leak it - modules.push_back(std::unique_ptr(lex)); - - // The external lexer needs to know how to call into its DLL to - // do its lexing and folding, we tell it here. - lex->SetExternal(fnFactory, i); - } - } - } -} - -LexerLibrary::~LexerLibrary() = default; - -//------------------------------------------ -// -// LexerManager -// -//------------------------------------------ - -/// Return the single LexerManager instance... -LexerManager *LexerManager::GetInstance() { - if (!theInstance) - theInstance.reset(new LexerManager); - return theInstance.get(); -} - -/// Delete any LexerManager instance... -void LexerManager::DeleteInstance() noexcept { - theInstance.reset(); -} - -/// protected constructor - this is a singleton... -LexerManager::LexerManager() = default; - -LexerManager::~LexerManager() { - Clear(); -} - -void LexerManager::Load(const char *path) { - for (const std::unique_ptr &ll : libraries) { - if (ll->moduleName == path) - return; - } - libraries.push_back(std::make_unique(path)); -} - -void LexerManager::Clear() noexcept { - libraries.clear(); -} - -//------------------------------------------ -// -// LMMinder -- trigger to clean up at exit. -// -//------------------------------------------ - -LMMinder::~LMMinder() { - LexerManager::DeleteInstance(); -} - -LMMinder minder; - -} - -namespace Scintilla { - -void ExternalLexerLoad(const char *path) { - LexerManager::GetInstance()->Load(path); -} - -} diff --git a/scintilla/src/ExternalLexer.h b/scintilla/src/ExternalLexer.h deleted file mode 100644 index d0a615e31..000000000 --- a/scintilla/src/ExternalLexer.h +++ /dev/null @@ -1,17 +0,0 @@ -// Scintilla source code edit control -/** @file ExternalLexer.h - ** Support external lexers in DLLs or shared libraries. - **/ -// Copyright 2001 Simon Steele , portions copyright Neil Hodgson. -// The License.txt file describes the conditions under which this software may be distributed. - -#ifndef EXTERNALLEXER_H -#define EXTERNALLEXER_H - -namespace Scintilla { - -void ExternalLexerLoad(const char *path); - -} - -#endif diff --git a/scintilla/src/UniConversion.h b/scintilla/src/UniConversion.h index c65fcc6f9..4568e2dea 100644 --- a/scintilla/src/UniConversion.h +++ b/scintilla/src/UniConversion.h @@ -75,7 +75,7 @@ inline bool UTF8IsNEL(const unsigned char *us) noexcept { return (us[0] == 0xc2) && (us[1] == 0x85); } -// Is the sequence of 3 char a UTF-8 line end? Only the last two char are tested for a NEL. +// Is the sequence of 3 char a UTF-8 line end? Only the last two char are tested for a NEL. constexpr bool UTF8IsMultibyteLineEnd(unsigned char ch0, unsigned char ch1, unsigned char ch2) noexcept { return ((ch0 == 0xe2) && (ch1 == 0x80) && ((ch2 == 0xa8) || (ch2 == 0xa9))) || diff --git a/scintilla/version.txt b/scintilla/version.txt index 018783526..1b79f38e2 100644 --- a/scintilla/version.txt +++ b/scintilla/version.txt @@ -1 +1 @@ -446 +500 diff --git a/scintilla/win32/DepGen.py b/scintilla/win32/DepGen.py index 563cae2a1..72ae027a5 100644 --- a/scintilla/win32/DepGen.py +++ b/scintilla/win32/DepGen.py @@ -13,8 +13,8 @@ from scripts import Dependencies topComment = "# Created by DepGen.py. To recreate, run DepGen.py.\n" def Generate(): - sources = ["../src/*.cxx", "../lexlib/*.cxx", "../lexers/*.cxx"] - includes = ["../include", "../src", "../lexlib"] + sources = ["../src/*.cxx"] + includes = ["../include", "../src"] # Create the dependencies file for g++ deps = Dependencies.FindDependencies(["../win32/*.cxx"] + sources, ["../win32"] + includes, ".o", "../win32/") diff --git a/scintilla/win32/HanjaDic.cxx b/scintilla/win32/HanjaDic.cxx index 72aa89a92..3daf16681 100644 --- a/scintilla/win32/HanjaDic.cxx +++ b/scintilla/win32/HanjaDic.cxx @@ -22,7 +22,7 @@ interface IRadical; interface IHanja; interface IStrokes; -enum HANJA_TYPE { HANJA_UNKNOWN = 0, HANJA_K0 = 1, HANJA_K1 = 2, HANJA_OTHER = 3 }; +typedef enum { HANJA_UNKNOWN = 0, HANJA_K0 = 1, HANJA_K1 = 2, HANJA_OTHER = 3 } HANJA_TYPE; interface IHanjaDic : IUnknown { STDMETHOD(OpenMainDic)(); @@ -104,10 +104,10 @@ int GetHangulOfHanja(wchar_t *inout) noexcept { int changed = 0; HanjaDic dict; if (dict.HJdictAvailable()) { - const size_t len = lstrlenW(inout); - wchar_t conv[UTF8MaxBytes] = { 0 }; + const size_t len = wcslen(inout); + wchar_t conv[UTF8MaxBytes] = {0}; BSTR bstrHangul = SysAllocString(conv); - for (size_t i = 0; i < len; i++) { + for (size_t i=0; i(inout[i]))) { // Pass hanja only! conv[0] = inout[i]; BSTR bstrHanja = SysAllocString(conv); diff --git a/scintilla/win32/ScintRes.rc b/scintilla/win32/ScintRes.rc index 8ea2fd1c7..e62fc25d8 100644 --- a/scintilla/win32/ScintRes.rc +++ b/scintilla/win32/ScintRes.rc @@ -1,13 +1,13 @@ // Resource file for Scintilla // encoding: UTF-8 #pragma code_page(65001) // UTF-8 -// Copyright 1998-2020 by Neil Hodgson +// Copyright 1998-2021 by Neil Hodgson // The License.txt file describes the conditions under which this software may be distributed. #include -#define VERSION_SCINTILLA "4.4.6" -#define VERSION_WORDS 4, 4, 6, 0 +#define VERSION_SCINTILLA "5.0.0" +#define VERSION_WORDS 5, 0, 0, 0 VS_VERSION_INFO VERSIONINFO FILEVERSION VERSION_WORDS