From 9e5581f484b3118be27201bbe89eb3768c9fc082 Mon Sep 17 00:00:00 2001 From: Sven Strickroth Date: Wed, 20 Jan 2016 23:19:13 +0100 Subject: [PATCH] Update Scintilla to 3.6.3 Signed-off-by: Sven Strickroth --- ext/scintilla/README | 26 +++- ext/scintilla/include/Platform.h | 2 +- ext/scintilla/include/Scintilla.h | 8 +- ext/scintilla/include/Scintilla.iface | 21 ++- ext/scintilla/include/ScintillaWidget.h | 27 +++- ext/scintilla/lexers/LexA68k.cxx | 178 +++++++++++------------ ext/scintilla/lexers/LexAVS.cxx | 2 +- ext/scintilla/lexers/LexBash.cxx | 82 ++++++++--- ext/scintilla/lexers/LexCPP.cxx | 6 +- ext/scintilla/lexers/LexCoffeeScript.cxx | 4 + ext/scintilla/lexers/LexECL.cxx | 12 +- ext/scintilla/lexers/LexErrorList.cxx | 5 + ext/scintilla/lexers/LexInno.cxx | 2 +- ext/scintilla/lexers/LexKVIrc.cxx | 2 +- ext/scintilla/lexers/LexLaTeX.cxx | 10 +- ext/scintilla/lexers/LexLua.cxx | 2 +- ext/scintilla/lexers/LexMarkdown.cxx | 2 +- ext/scintilla/lexers/LexMatlab.cxx | 10 +- ext/scintilla/lexers/LexMySQL.cxx | 16 +- ext/scintilla/lexers/LexOScript.cxx | 4 +- ext/scintilla/lexers/LexPB.cxx | 2 +- ext/scintilla/lexers/LexPO.cxx | 32 ++-- ext/scintilla/lexers/LexPerl.cxx | 134 +++++++++++++---- ext/scintilla/lexers/LexRust.cxx | 6 +- ext/scintilla/lexers/LexSML.cxx | 4 +- ext/scintilla/lexers/LexSQL.cxx | 10 +- ext/scintilla/lexers/LexTCMD.cxx | 4 +- ext/scintilla/lexers/LexVisualProlog.cxx | 17 ++- ext/scintilla/src/CellBuffer.cxx | 19 +++ ext/scintilla/src/CellBuffer.h | 1 + ext/scintilla/src/Document.cxx | 44 +++++- ext/scintilla/src/Document.h | 8 +- ext/scintilla/src/EditModel.h | 2 +- ext/scintilla/src/EditView.cxx | 104 ++++++------- ext/scintilla/src/EditView.h | 1 - ext/scintilla/src/Editor.cxx | 242 +++++++++++++++++++++---------- ext/scintilla/src/Editor.h | 9 +- ext/scintilla/src/Indicator.cxx | 2 +- ext/scintilla/src/PerLine.cxx | 3 +- ext/scintilla/src/RESearch.cxx | 2 +- ext/scintilla/src/ScintillaBase.cxx | 4 +- ext/scintilla/src/Selection.cxx | 4 + ext/scintilla/src/Selection.h | 1 + ext/scintilla/src/UniConversion.cxx | 4 - ext/scintilla/src/UniConversion.h | 4 + ext/scintilla/src/ViewStyle.cxx | 51 +++++-- ext/scintilla/src/ViewStyle.h | 6 +- ext/scintilla/version.txt | 2 +- ext/scintilla/win32/PlatWin.cxx | 119 +++++++-------- ext/scintilla/win32/ScintRes.rc | 4 +- ext/scintilla/win32/ScintillaWin.cxx | 185 +++++++++++++---------- ext/scintilla/win32/makefile | 8 +- ext/scintilla/win32/scintilla.mak | 13 +- 53 files changed, 915 insertions(+), 557 deletions(-) diff --git a/ext/scintilla/README b/ext/scintilla/README index 3fe033e7f..b4f84d941 100644 --- a/ext/scintilla/README +++ b/ext/scintilla/README @@ -6,7 +6,7 @@ To build SciTE, Scintilla must first be built. *** GTK+/Linux version *** -You must first have GTK+ 2.0 or later and GCC (4.1 or better) installed. +You must first have GTK+ 2.18 or later and GCC (4.8 or better) installed. GTK+ 1.x will not work. Other C++ compilers may work but may require tweaking the make file. @@ -18,7 +18,7 @@ To build Scintilla, use the makefile located in the scintilla/gtk directory To build and install SciTE, use the makefile located in the scite/gtk directory cd scite/gtk make - make install + sudo make install This installs SciTE into $prefix/bin. The value of $prefix is determined from the location of Gnome if it is installed. This is usually /usr if installed @@ -30,7 +30,7 @@ properties file is installed at $prefix/share/scite/SciTEGlobal.properties. The language specific properties files are also installed into this directory. To remove SciTE - make uninstall + sudo make uninstall To clean the object files which may be needed to change $prefix make clean @@ -40,8 +40,9 @@ The current make file only supports static linking between SciTE and Scintilla. *** Windows version *** -A C++ compiler is required. Visual Studio 2010 is the development system -used for most development although TDM Mingw32 4.7.1 is also supported. +A C++ compiler is required, with C++11 required for building SciTE. +Visual Studio 2015 is the development system used for most development +although Mingw32 4.8 is also supported. To build Scintilla, make in the scintilla/win32 directory cd scintilla\win32 @@ -65,3 +66,18 @@ Only Scintilla will build with GTK+ on Windows. SciTE will not work. To build Scintilla, make in the scintilla/gtk directory cd scintilla\gtk mingw32-make + +*** OS X Cocoa version *** + +Xcode 6 or 7 may be used to build Scintilla on OS X. + +There is no open source version of SciTE for OS X but there is a commercial +version available through the App Store. + +To build Scintilla, run xcodebuild in the scintilla/cocoa/ScintillaFramework directory + cd cocoa/ScintillaFramework + xcodebuild + +*** Qt version *** + +See the qt/README file to build Scintilla with Qt. diff --git a/ext/scintilla/include/Platform.h b/ext/scintilla/include/Platform.h index dbc986da7..28d34f45d 100644 --- a/ext/scintilla/include/Platform.h +++ b/ext/scintilla/include/Platform.h @@ -145,7 +145,7 @@ public: (pt.y >= top) && (pt.y <= bottom); } bool ContainsWholePixel(Point pt) const { - // Does the rectangle contain all of the pixel to left/below the point + // 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); } diff --git a/ext/scintilla/include/Scintilla.h b/ext/scintilla/include/Scintilla.h index ae991914d..c74253441 100644 --- a/ext/scintilla/include/Scintilla.h +++ b/ext/scintilla/include/Scintilla.h @@ -73,6 +73,7 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SCWS_INVISIBLE 0 #define SCWS_VISIBLEALWAYS 1 #define SCWS_VISIBLEAFTERINDENT 2 +#define SCWS_VISIBLEONLYININDENT 3 #define SCI_GETVIEWWS 2020 #define SCI_SETVIEWWS 2021 #define SCI_POSITIONFROMPOINT 2022 @@ -505,6 +506,12 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SCI_WORDSTARTPOSITION 2266 #define SCI_WORDENDPOSITION 2267 #define SCI_ISRANGEWORD 2691 +#define SC_IDLESTYLING_NONE 0 +#define SC_IDLESTYLING_TOVISIBLE 1 +#define SC_IDLESTYLING_AFTERVISIBLE 2 +#define SC_IDLESTYLING_ALL 3 +#define SCI_SETIDLESTYLING 2692 +#define SCI_GETIDLESTYLING 2693 #define SC_WRAP_NONE 0 #define SC_WRAP_WORD 1 #define SC_WRAP_CHAR 2 @@ -1062,7 +1069,6 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SCN_FOCUSIN 2028 #define SCN_FOCUSOUT 2029 #define SCN_AUTOCCOMPLETED 2030 -#define SCN_GETBKCOLOR 5000 /* --Autogenerated -- end of section automatically generated from Scintilla.iface */ /* These structures are defined to be exactly the same shape as the Win32 diff --git a/ext/scintilla/include/Scintilla.iface b/ext/scintilla/include/Scintilla.iface index 64521800d..ff37ce14f 100644 --- a/ext/scintilla/include/Scintilla.iface +++ b/ext/scintilla/include/Scintilla.iface @@ -159,6 +159,7 @@ enu WhiteSpace=SCWS_ val SCWS_INVISIBLE=0 val SCWS_VISIBLEALWAYS=1 val SCWS_VISIBLEAFTERINDENT=2 +val SCWS_VISIBLEONLYININDENT=3 # Are white space characters currently visible? # Returns one of SCWS_* constants. @@ -248,11 +249,11 @@ enu IMEInteraction=SC_IME_ val SC_IME_WINDOWED=0 val SC_IME_INLINE=1 -# Is the IME displayed in a winow or inline? +# Is the IME displayed in a window or inline? get int GetIMEInteraction=2678(,) # Choose to display the the IME in a winow or inline. -set void SetIMEInteraction=2679(int imeInteraction,) +set void SetIMEInteraction=2679(int imeInteraction,) enu MarkerSymbol=SC_MARK_ val MARKER_MAX=31 @@ -1259,6 +1260,18 @@ fun int WordEndPosition=2267(position pos, bool onlyWordCharacters) # Is the range start..end considered a word? fun bool IsRangeWord=2691(position start, position end) +enu IdleStyling=SC_IDLESTYLING_ +val SC_IDLESTYLING_NONE=0 +val SC_IDLESTYLING_TOVISIBLE=1 +val SC_IDLESTYLING_AFTERVISIBLE=2 +val SC_IDLESTYLING_ALL=3 + +# Sets limits to idle styling. +set void SetIdleStyling=2692(int idleStyling,) + +# Retrieve the limits to idle styling. +get int GetIdleStyling=2693(,) + enu Wrap=SC_WRAP_ val SC_WRAP_NONE=0 val SC_WRAP_WORD=1 @@ -1407,7 +1420,7 @@ val SC_MULTIPASTE_EACH=1 # Change the effect of pasting when there are multiple selections. set void SetMultiPaste=2614(int multiPaste,) -# Retrieve the effect of pasting when there are multiple selections.. +# Retrieve the effect of pasting when there are multiple selections. get int GetMultiPaste=2615(,) # Retrieve the value of a tag from a regular expression search. @@ -1976,7 +1989,7 @@ val SC_MULTIAUTOC_EACH=1 # Change the effect of autocompleting when there are multiple selections. set void AutoCSetMulti=2636(int multi,) -# Retrieve the effect of autocompleting when there are multiple selections.. +# Retrieve the effect of autocompleting when there are multiple selections. get int AutoCGetMulti=2637(,) enu Ordering=SC_ORDER_ diff --git a/ext/scintilla/include/ScintillaWidget.h b/ext/scintilla/include/ScintillaWidget.h index 0ae8fabda..8409c655b 100644 --- a/ext/scintilla/include/ScintillaWidget.h +++ b/ext/scintilla/include/ScintillaWidget.h @@ -1,8 +1,9 @@ /* Scintilla source code edit control */ -/** @file ScintillaWidget.h - ** Definition of Scintilla widget for GTK+. - ** Only needed by GTK+ code but is harmless on other platforms. - **/ +/* @file ScintillaWidget.h + * Definition of Scintilla widget for GTK+. + * Only needed by GTK+ code but is harmless on other platforms. + * This comment is not a doc-comment as that causes warnings from g-ir-scanner. + */ /* Copyright 1998-2001 by Neil Hodgson * The License.txt file describes the conditions under which this software may be distributed. */ @@ -19,8 +20,15 @@ extern "C" { #define SCINTILLA_CLASS(klass) G_TYPE_CHECK_CLASS_CAST (klass, scintilla_get_type (), ScintillaClass) #define IS_SCINTILLA(obj) G_TYPE_CHECK_INSTANCE_TYPE (obj, scintilla_get_type ()) +#define SCINTILLA_TYPE_OBJECT (scintilla_object_get_type()) +#define SCINTILLA_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), SCINTILLA_TYPE_OBJECT, ScintillaObject)) +#define SCINTILLA_IS_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SCINTILLA_TYPE_OBJECT)) +#define SCINTILLA_OBJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), SCINTILLA_TYPE_OBJECT, ScintillaObjectClass)) +#define SCINTILLA_IS_OBJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), SCINTILLA_TYPE_OBJECT)) +#define SCINTILLA_OBJECT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), SCINTILLA_TYPE_OBJECT, ScintillaObjectClass)) + typedef struct _ScintillaObject ScintillaObject; -typedef struct _ScintillaClass ScintillaClass; +typedef struct _ScintillaClass ScintillaObjectClass; struct _ScintillaObject { GtkContainer cont; @@ -34,11 +42,20 @@ struct _ScintillaClass { void (* notify) (ScintillaObject *ttt); }; +GType scintilla_object_get_type (void); +GtkWidget* scintilla_object_new (void); +long scintilla_object_send_message (ScintillaObject *sci, unsigned int iMessage, guintptr wParam, gintptr lParam); + +#ifndef G_IR_SCANNING +/* The legacy names confuse the g-ir-scanner program */ +typedef struct _ScintillaClass ScintillaClass; + GType scintilla_get_type (void); GtkWidget* scintilla_new (void); void scintilla_set_id (ScintillaObject *sci, uptr_t id); sptr_t scintilla_send_message (ScintillaObject *sci,unsigned int iMessage, uptr_t wParam, sptr_t lParam); void scintilla_release_resources(void); +#endif #define SCINTILLA_NOTIFY "sci-notify" diff --git a/ext/scintilla/lexers/LexA68k.cxx b/ext/scintilla/lexers/LexA68k.cxx index 59c0cd5be..aa403e22a 100644 --- a/ext/scintilla/lexers/LexA68k.cxx +++ b/ext/scintilla/lexers/LexA68k.cxx @@ -117,20 +117,20 @@ static inline bool IsDoxygenChar (const int ch) static void ColouriseA68kDoc (Sci_PositionU startPos, Sci_Position length, int initStyle, WordList *keywordlists[], Accessor &styler) { - // Used to buffer a string, to be able to compare it using built-in functions - char Buffer[100]; - - - // Used to know the length of an operator - int OpType; - + // Used to buffer a string, to be able to compare it using built-in functions + char Buffer[100]; + + + // Used to know the length of an operator + int OpType; + // Get references to keywords lists WordList &cpuInstruction = *keywordlists[0]; WordList ®isters = *keywordlists[1]; WordList &directive = *keywordlists[2]; WordList &extInstruction = *keywordlists[3]; - WordList &alert = *keywordlists[4]; + WordList &alert = *keywordlists[4]; WordList &doxygenKeyword = *keywordlists[5]; @@ -140,109 +140,109 @@ static void ColouriseA68kDoc (Sci_PositionU startPos, Sci_Position length, int i /************************************************************ * - * Parse the source + * Parse the source * ************************************************************/ for ( ; sc.More(); sc.Forward()) { - /************************************************************ - * - * A style always terminates at the end of a line, even for - * comments (no multi-lines comments) - * - ************************************************************/ - if (sc.atLineStart) { + /************************************************************ + * + * A style always terminates at the end of a line, even for + * comments (no multi-lines comments) + * + ************************************************************/ + if (sc.atLineStart) { sc.SetState(SCE_A68K_DEFAULT); - } + } /************************************************************ * - * If we are not in "default style", check if the style continues - * In this case, we just have to loop + * If we are not in "default style", check if the style continues + * In this case, we just have to loop * ************************************************************/ if (sc.state != SCE_A68K_DEFAULT) { - if ( ((sc.state == SCE_A68K_NUMBER_DEC) && isdigit(sc.ch)) // Decimal number + if ( ((sc.state == SCE_A68K_NUMBER_DEC) && isdigit(sc.ch)) // Decimal number || ((sc.state == SCE_A68K_NUMBER_BIN) && IsBin(sc.ch)) // Binary number || ((sc.state == SCE_A68K_NUMBER_HEX) && isxdigit(sc.ch)) // Hexa number - || ((sc.state == SCE_A68K_MACRO_ARG) && isdigit(sc.ch)) // Macro argument + || ((sc.state == SCE_A68K_MACRO_ARG) && isdigit(sc.ch)) // Macro argument || ((sc.state == SCE_A68K_STRING1) && (sc.ch != '\'')) // String single-quoted || ((sc.state == SCE_A68K_STRING2) && (sc.ch != '\"')) // String double-quoted - || ((sc.state == SCE_A68K_MACRO_DECLARATION) && IsIdentifierChar(sc.ch)) // Macro declaration (or global label, we don't know at this point) - || ((sc.state == SCE_A68K_IDENTIFIER) && IsIdentifierChar(sc.ch)) // Identifier - || ((sc.state == SCE_A68K_LABEL) && IsIdentifierChar(sc.ch)) // Label (local) - || ((sc.state == SCE_A68K_COMMENT_DOXYGEN) && IsDoxygenChar(sc.ch)) // Doxygen keyword - || ((sc.state == SCE_A68K_COMMENT_SPECIAL) && isalpha(sc.ch)) // Alert - || ((sc.state == SCE_A68K_COMMENT) && !isalpha(sc.ch) && (sc.ch != '\\'))) // Normal comment + || ((sc.state == SCE_A68K_MACRO_DECLARATION) && IsIdentifierChar(sc.ch)) // Macro declaration (or global label, we don't know at this point) + || ((sc.state == SCE_A68K_IDENTIFIER) && IsIdentifierChar(sc.ch)) // Identifier + || ((sc.state == SCE_A68K_LABEL) && IsIdentifierChar(sc.ch)) // Label (local) + || ((sc.state == SCE_A68K_COMMENT_DOXYGEN) && IsDoxygenChar(sc.ch)) // Doxygen keyword + || ((sc.state == SCE_A68K_COMMENT_SPECIAL) && isalpha(sc.ch)) // Alert + || ((sc.state == SCE_A68K_COMMENT) && !isalpha(sc.ch) && (sc.ch != '\\'))) // Normal comment { continue; } - /************************************************************ - * - * Check if current state terminates - * - ************************************************************/ + /************************************************************ + * + * Check if current state terminates + * + ************************************************************/ - // Strings: include terminal ' or " in the current string by skipping it - if ((sc.state == SCE_A68K_STRING1) || (sc.state == SCE_A68K_STRING2)) { - sc.Forward(); + // Strings: include terminal ' or " in the current string by skipping it + if ((sc.state == SCE_A68K_STRING1) || (sc.state == SCE_A68K_STRING2)) { + sc.Forward(); } - - - // If a macro declaration was terminated with ':', it was a label - else if ((sc.state == SCE_A68K_MACRO_DECLARATION) && (sc.chPrev == ':')) { - sc.ChangeState(SCE_A68K_LABEL); + + + // If a macro declaration was terminated with ':', it was a label + else if ((sc.state == SCE_A68K_MACRO_DECLARATION) && (sc.chPrev == ':')) { + sc.ChangeState(SCE_A68K_LABEL); } - - // If it wasn't a Doxygen keyword, change it to normal comment - else if (sc.state == SCE_A68K_COMMENT_DOXYGEN) { + + // If it wasn't a Doxygen keyword, change it to normal comment + else if (sc.state == SCE_A68K_COMMENT_DOXYGEN) { sc.GetCurrent(Buffer, sizeof(Buffer)); - if (!doxygenKeyword.InList(Buffer)) { + if (!doxygenKeyword.InList(Buffer)) { sc.ChangeState(SCE_A68K_COMMENT); } sc.SetState(SCE_A68K_COMMENT); continue; } - - // If it wasn't an Alert, change it to normal comment - else if (sc.state == SCE_A68K_COMMENT_SPECIAL) { - sc.GetCurrent(Buffer, sizeof(Buffer)); - if (!alert.InList(Buffer)) { + + // If it wasn't an Alert, change it to normal comment + else if (sc.state == SCE_A68K_COMMENT_SPECIAL) { + sc.GetCurrent(Buffer, sizeof(Buffer)); + if (!alert.InList(Buffer)) { sc.ChangeState(SCE_A68K_COMMENT); } - // Reset style to normal comment, or to Doxygen keyword if it begins with '\' - if (sc.ch == '\\') { - sc.SetState(SCE_A68K_COMMENT_DOXYGEN); - } - else { + // Reset style to normal comment, or to Doxygen keyword if it begins with '\' + if (sc.ch == '\\') { + sc.SetState(SCE_A68K_COMMENT_DOXYGEN); + } + else { sc.SetState(SCE_A68K_COMMENT); - } + } continue; } - - // If we are in a comment, it's a Doxygen keyword or an Alert - else if (sc.state == SCE_A68K_COMMENT) { - if (sc.ch == '\\') { - sc.SetState(SCE_A68K_COMMENT_DOXYGEN); - } - else { - sc.SetState(SCE_A68K_COMMENT_SPECIAL); - } - continue; + + // If we are in a comment, it's a Doxygen keyword or an Alert + else if (sc.state == SCE_A68K_COMMENT) { + if (sc.ch == '\\') { + sc.SetState(SCE_A68K_COMMENT_DOXYGEN); + } + else { + sc.SetState(SCE_A68K_COMMENT_SPECIAL); + } + continue; } - + // Check if we are at the end of an identifier // In this case, colourise it if was a keyword. - else if ((sc.state == SCE_A68K_IDENTIFIER) && !IsIdentifierChar(sc.ch)) { + else if ((sc.state == SCE_A68K_IDENTIFIER) && !IsIdentifierChar(sc.ch)) { sc.GetCurrentLowered(Buffer, sizeof(Buffer)); // Buffer the string of the current context if (cpuInstruction.InList(Buffer)) { // And check if it belongs to a keyword list sc.ChangeState(SCE_A68K_CPUINSTRUCTION); @@ -269,30 +269,30 @@ static void ColouriseA68kDoc (Sci_PositionU startPos, Sci_Position length, int i * ************************************************************/ - // Something which begins at the beginning of a line, and with - // - '\' + an identifier start char, or - // - '\\@' + an identifier start char - // is a local label (second case is used for macro local labels). We set it already as a label, it can't be a macro/equ declaration - if (sc.atLineStart && (sc.ch < 0x80) && IsIdentifierStart(sc.chNext) && (sc.ch == '\\')) { - sc.SetState(SCE_A68K_LABEL); - } - - if (sc.atLineStart && (sc.ch < 0x80) && (sc.ch == '\\') && (sc.chNext == '\\')) { - sc.Forward(2); - if ((sc.ch == '@') && IsIdentifierStart(sc.chNext)) { - sc.ChangeState(SCE_A68K_LABEL); - sc.SetState(SCE_A68K_LABEL); - } - } - + // Something which begins at the beginning of a line, and with + // - '\' + an identifier start char, or + // - '\\@' + an identifier start char + // is a local label (second case is used for macro local labels). We set it already as a label, it can't be a macro/equ declaration + if (sc.atLineStart && (sc.ch < 0x80) && IsIdentifierStart(sc.chNext) && (sc.ch == '\\')) { + sc.SetState(SCE_A68K_LABEL); + } + + if (sc.atLineStart && (sc.ch < 0x80) && (sc.ch == '\\') && (sc.chNext == '\\')) { + sc.Forward(2); + if ((sc.ch == '@') && IsIdentifierStart(sc.chNext)) { + sc.ChangeState(SCE_A68K_LABEL); + sc.SetState(SCE_A68K_LABEL); + } + } + // Label and macro identifiers start at the beginning of a line - // We set both as a macro id, but if it wasn't one (':' at the end), - // it will be changed as a label. + // We set both as a macro id, but if it wasn't one (':' at the end), + // it will be changed as a label. if (sc.atLineStart && (sc.ch < 0x80) && IsIdentifierStart(sc.ch)) { - sc.SetState(SCE_A68K_MACRO_DECLARATION); + sc.SetState(SCE_A68K_MACRO_DECLARATION); } - else if ((sc.ch < 0x80) && (sc.ch == ';')) { // Default: alert in a comment. If it doesn't match - sc.SetState(SCE_A68K_COMMENT); // with an alert, it will be toggle to a normal comment + else if ((sc.ch < 0x80) && (sc.ch == ';')) { // Default: alert in a comment. If it doesn't match + sc.SetState(SCE_A68K_COMMENT); // with an alert, it will be toggle to a normal comment } else if ((sc.ch < 0x80) && isdigit(sc.ch)) { // Decimal numbers haven't prefix sc.SetState(SCE_A68K_NUMBER_DEC); @@ -309,7 +309,7 @@ static void ColouriseA68kDoc (Sci_PositionU startPos, Sci_Position length, int i else if ((sc.ch < 0x80) && (sc.ch == '\"')) { // String (double-quoted) sc.SetState(SCE_A68K_STRING2); } - else if ((sc.ch < 0x80) && (sc.ch == '\\') && (isdigit(sc.chNext))) { // Replacement symbols in macro are prefixed with '\' + else if ((sc.ch < 0x80) && (sc.ch == '\\') && (isdigit(sc.chNext))) { // Replacement symbols in macro are prefixed with '\' sc.SetState(SCE_A68K_MACRO_ARG); } else if ((sc.ch < 0x80) && IsIdentifierStart(sc.ch)) { // An identifier: constant, label, etc... diff --git a/ext/scintilla/lexers/LexAVS.cxx b/ext/scintilla/lexers/LexAVS.cxx index 551f1f490..20a6ef683 100644 --- a/ext/scintilla/lexers/LexAVS.cxx +++ b/ext/scintilla/lexers/LexAVS.cxx @@ -83,7 +83,7 @@ static void ColouriseAvsDoc( styler.SetLineState(currentLine, 0); } } - + // Determine if the current state should terminate. if (sc.state == SCE_AVS_OPERATOR) { sc.SetState(SCE_AVS_DEFAULT); diff --git a/ext/scintilla/lexers/LexBash.cxx b/ext/scintilla/lexers/LexBash.cxx index 14a4ec5b0..9582cc54a 100644 --- a/ext/scintilla/lexers/LexBash.cxx +++ b/ext/scintilla/lexers/LexBash.cxx @@ -96,6 +96,19 @@ static int opposite(int ch) { return ch; } +static int GlobScan(StyleContext &sc) { + // forward scan for a glob-like (...), no whitespace allowed + int c, sLen = 0; + while ((c = sc.GetRelativeCharacter(++sLen)) != 0) { + if (IsASpace(c)) { + return 0; + } else if (c == ')') { + return sLen; + } + } + return 0; +} + static void ColouriseBashDoc(Sci_PositionU startPos, Sci_Position length, int initStyle, WordList *keywordlists[], Accessor &styler) { @@ -113,9 +126,9 @@ static void ColouriseBashDoc(Sci_PositionU startPos, Sci_Position length, int in CharacterSet setBashOperator(CharacterSet::setNone, "^&%()-+=|{}[]:;>,*/ 1) { + sc.SetState(SCE_SH_IDENTIFIER); + sc.Forward(i); + continue; + } + } // handle opening delimiters for test/arithmetic expressions - ((,[[,[ if (cmdState == BASH_CMD_START || cmdState == BASH_CMD_BODY) { diff --git a/ext/scintilla/lexers/LexCPP.cxx b/ext/scintilla/lexers/LexCPP.cxx index 4d893c45f..dde27c76b 100644 --- a/ext/scintilla/lexers/LexCPP.cxx +++ b/ext/scintilla/lexers/LexCPP.cxx @@ -374,7 +374,7 @@ struct OptionSetCPP : public OptionSet { DefineProperty("lexer.cpp.verbatim.strings.allow.escapes", &OptionsCPP::verbatimStringsAllowEscapes, "Set to 1 to allow verbatim strings to contain escape sequences."); - + DefineProperty("lexer.cpp.triplequoted.strings", &OptionsCPP::triplequotedStrings, "Set to 1 to enable highlighting of triple-quoted strings."); @@ -1467,7 +1467,7 @@ void LexerCPP::EvaluateTokens(std::vector &tokens, const SymbolTabl } iMacro++; } - + // Insert results back into tokens tokens.insert(tokens.begin() + i, macroTokens.begin(), macroTokens.end()); @@ -1481,7 +1481,7 @@ void LexerCPP::EvaluateTokens(std::vector &tokens, const SymbolTabl tokens.insert(tokens.begin() + i, macroTokens.begin(), macroTokens.end()); } } else { - // Identifier not found + // Identifier not found tokens.erase(tokens.begin() + i); } } else { diff --git a/ext/scintilla/lexers/LexCoffeeScript.cxx b/ext/scintilla/lexers/LexCoffeeScript.cxx index 7e64b8503..51229b179 100644 --- a/ext/scintilla/lexers/LexCoffeeScript.cxx +++ b/ext/scintilla/lexers/LexCoffeeScript.cxx @@ -252,6 +252,10 @@ static void ColouriseCoffeeScriptDoc(Sci_PositionU startPos, Sci_Position length } } else if (isoperator(static_cast(sc.ch))) { sc.SetState(SCE_COFFEESCRIPT_OPERATOR); + // Handle '..' and '...' operators correctly. + if (sc.ch == '.') { + for (int i = 0; i < 2 && sc.chNext == '.'; i++, sc.Forward()) ; + } } } diff --git a/ext/scintilla/lexers/LexECL.cxx b/ext/scintilla/lexers/LexECL.cxx index 95a4780c6..4ab6c1bcd 100644 --- a/ext/scintilla/lexers/LexECL.cxx +++ b/ext/scintilla/lexers/LexECL.cxx @@ -175,7 +175,7 @@ static void ColouriseEclDoc(Sci_PositionU startPos, Sci_Position length, int ini } else if (keywords5.InList(s)) { sc.ChangeState(SCE_ECL_WORD5); } - else //Data types are of from KEYWORD## + else //Data types are of from KEYWORD## { int i = static_cast(strlen(s)) - 1; while(i >= 0 && (isdigit(s[i]) || s[i] == '_')) @@ -186,7 +186,7 @@ static void ColouriseEclDoc(Sci_PositionU startPos, Sci_Position length, int ini s2[i + 1] = 0; if (keywords3.InList(s2)) { sc.ChangeState(SCE_ECL_WORD3); - } + } } sc.SetState(SCE_ECL_DEFAULT); } @@ -388,12 +388,12 @@ static bool IsStreamCommentStyle(int style) { style == SCE_ECL_COMMENTDOCKEYWORDERROR; } -bool MatchNoCase(Accessor & styler, Sci_PositionU & pos, const char *s) { +static bool MatchNoCase(Accessor & styler, Sci_PositionU & pos, const char *s) { Sci_Position i=0; for (; *s; i++) { char compare_char = tolower(*s); char styler_char = tolower(styler.SafeGetCharAt(pos+i)); - if (compare_char != styler_char) + if (compare_char != styler_char) return false; s++; } @@ -405,7 +405,7 @@ bool MatchNoCase(Accessor & styler, Sci_PositionU & pos, const char *s) { // Store both the current line's fold level and the next lines in the // level store to make it easy to pick up with each increment // and to make it possible to fiddle the current level for "} else {". -static void FoldEclDoc(Sci_PositionU startPos, Sci_Position length, int initStyle, +static void FoldEclDoc(Sci_PositionU startPos, Sci_Position length, int initStyle, WordList *[], Accessor &styler) { bool foldComment = true; bool foldPreprocessor = true; @@ -473,7 +473,7 @@ static void FoldEclDoc(Sci_PositionU startPos, Sci_Position length, int initStyl } } if (style == SCE_ECL_WORD2) { - if (MatchNoCase(styler, i, "record") || MatchNoCase(styler, i, "transform") || MatchNoCase(styler, i, "type") || MatchNoCase(styler, i, "function") || + if (MatchNoCase(styler, i, "record") || MatchNoCase(styler, i, "transform") || MatchNoCase(styler, i, "type") || MatchNoCase(styler, i, "function") || MatchNoCase(styler, i, "module") || MatchNoCase(styler, i, "service") || MatchNoCase(styler, i, "interface") || MatchNoCase(styler, i, "ifblock") || MatchNoCase(styler, i, "macro") || MatchNoCase(styler, i, "beginc++")) { levelNext++; diff --git a/ext/scintilla/lexers/LexErrorList.cxx b/ext/scintilla/lexers/LexErrorList.cxx index 11e7bc680..913d58778 100644 --- a/ext/scintilla/lexers/LexErrorList.cxx +++ b/ext/scintilla/lexers/LexErrorList.cxx @@ -127,6 +127,10 @@ static int RecogniseErrorListLine(const char *lineBuffer, Sci_PositionU lengthLi strstart(lineBuffer, " from ")) { // GCC showing include path to following error return SCE_ERR_GCC_INCLUDED_FROM; + } else if (strstr(lineBuffer, "warning LNK")) { + // Microsoft linker warning: + // { : } warning LNK9999 + return SCE_ERR_MS; } else { // Look for one of the following formats: // GCC: :: @@ -374,6 +378,7 @@ static void ColouriseErrorListDoc(Sci_PositionU startPos, Sci_Position length, i } } if (linePos > 0) { // Last line does not have ending characters + lineBuffer[linePos] = '\0'; ColouriseErrorListLine(lineBuffer, linePos, startPos + length - 1, styler, valueSeparate, escapeSequences); } } diff --git a/ext/scintilla/lexers/LexInno.cxx b/ext/scintilla/lexers/LexInno.cxx index 8db83496a..5f6844005 100644 --- a/ext/scintilla/lexers/LexInno.cxx +++ b/ext/scintilla/lexers/LexInno.cxx @@ -33,7 +33,7 @@ static void ColouriseInnoDoc(Sci_PositionU startPos, Sci_Position length, int, W char ch = 0; char chNext = styler[startPos]; Sci_Position lengthDoc = startPos + length; - char *buffer = new char[length]; + char *buffer = new char[length+1]; Sci_Position bufferCount = 0; bool isBOL, isEOL, isWS, isBOLWS = 0; bool isCStyleComment = false; diff --git a/ext/scintilla/lexers/LexKVIrc.cxx b/ext/scintilla/lexers/LexKVIrc.cxx index e32877b41..8b83b4d5e 100644 --- a/ext/scintilla/lexers/LexKVIrc.cxx +++ b/ext/scintilla/lexers/LexKVIrc.cxx @@ -359,7 +359,7 @@ static void FoldKVIrcDoc(Sci_PositionU startPos, Sci_Position length, int /*init WordList *[], Accessor &styler) { /* Based on CMake's folder */ - + /* Exiting if folding isnt enabled */ if ( styler.GetPropertyInt("fold") == 0 ) return; diff --git a/ext/scintilla/lexers/LexLaTeX.cxx b/ext/scintilla/lexers/LexLaTeX.cxx index ad1e82dd2..5f2c48e09 100644 --- a/ext/scintilla/lexers/LexLaTeX.cxx +++ b/ext/scintilla/lexers/LexLaTeX.cxx @@ -60,7 +60,7 @@ private: if (static_cast(modes.size()) > numLines * 2 + 256) modes.resize(numLines + 128); } - + vector saves; void setSave(Sci_Position line, const latexFoldSave &save) { if (line >= static_cast(saves.size())) saves.resize(line + 1); @@ -192,7 +192,7 @@ void SCI_METHOD LexerLaTeX::Lex(Sci_PositionU startPos, Sci_Position length, int int state = initStyle; if (state == SCE_L_ERROR || state == SCE_L_SHORTCMD || state == SCE_L_SPECIAL) // should not happen latexStateReset(mode, state); - + char chNext = styler.SafeGetCharAt(startPos); char chVerbatimDelim = '\0'; styler.StartSegment(startPos); @@ -207,7 +207,7 @@ void SCI_METHOD LexerLaTeX::Lex(Sci_PositionU startPos, Sci_Position length, int chNext = styler.SafeGetCharAt(i + 1); continue; } - + if (ch == '\r' || ch == '\n') setMode(styler.GetLine(i), mode); @@ -256,7 +256,7 @@ void SCI_METHOD LexerLaTeX::Lex(Sci_PositionU startPos, Sci_Position length, int state = SCE_L_COMMENT; break; } - break; + break; // These 3 will never be reached. case SCE_L_ERROR: case SCE_L_SPECIAL: @@ -400,7 +400,7 @@ void SCI_METHOD LexerLaTeX::Lex(Sci_PositionU startPos, Sci_Position length, int chNext = styler.SafeGetCharAt(i + 1); mode = 0; state = SCE_L_DEFAULT; - } else { // This may not be an error, e.g. \begin{equation}\text{$a$}\end{equation} + } else { // This may not be an error, e.g. \begin{equation}\text{$a$}\end{equation} styler.ColourTo(i, SCE_L_SHORTCMD); } break; diff --git a/ext/scintilla/lexers/LexLua.cxx b/ext/scintilla/lexers/LexLua.cxx index 09bab27b0..0647d2ca1 100644 --- a/ext/scintilla/lexers/LexLua.cxx +++ b/ext/scintilla/lexers/LexLua.cxx @@ -64,7 +64,7 @@ static void ColouriseLuaDoc( // but probably enough in most cases. [pP] is for hex floats. CharacterSet setNumber(CharacterSet::setDigits, ".-+abcdefpABCDEFP"); CharacterSet setExponent(CharacterSet::setNone, "eEpP"); - CharacterSet setLuaOperator(CharacterSet::setNone, "*/-+()={}~[];<>,.^%:#"); + CharacterSet setLuaOperator(CharacterSet::setNone, "*/-+()={}~[];<>,.^%:#&|"); CharacterSet setEscapeSkip(CharacterSet::setNone, "\"'\\"); Sci_Position currentLine = styler.GetLine(startPos); diff --git a/ext/scintilla/lexers/LexMarkdown.cxx b/ext/scintilla/lexers/LexMarkdown.cxx index 6729ca54b..9562882b2 100644 --- a/ext/scintilla/lexers/LexMarkdown.cxx +++ b/ext/scintilla/lexers/LexMarkdown.cxx @@ -114,7 +114,7 @@ static bool HasPrevLineContent(StyleContext &sc) { } static bool AtTermStart(StyleContext &sc) { - return sc.currentPos == 0 || isspacechar(sc.chPrev); + return sc.currentPos == 0 || sc.chPrev == 0 || isspacechar(sc.chPrev); } static bool IsValidHrule(const Sci_PositionU endPos, StyleContext &sc) { diff --git a/ext/scintilla/lexers/LexMatlab.cxx b/ext/scintilla/lexers/LexMatlab.cxx index 778037011..f20f73261 100644 --- a/ext/scintilla/lexers/LexMatlab.cxx +++ b/ext/scintilla/lexers/LexMatlab.cxx @@ -67,7 +67,7 @@ static void ColouriseMatlabOctaveDoc( styler.StartAt(startPos); - // boolean for when the ' is allowed to be transpose vs the start/end + // boolean for when the ' is allowed to be transpose vs the start/end // of a string bool transpose = false; @@ -86,13 +86,13 @@ static void ColouriseMatlabOctaveDoc( for (; sc.More(); sc.Forward(), column++) { if(sc.atLineStart) { - // set the line state to the current commentDepth + // set the line state to the current commentDepth curLine = styler.GetLine(sc.currentPos); styler.SetLineState(curLine, commentDepth); // reset the column to 0, nonSpace to -1 (not set) column = 0; - nonSpaceColumn = -1; + nonSpaceColumn = -1; } // save the column position of first non space character in a line @@ -111,7 +111,7 @@ static void ColouriseMatlabOctaveDoc( sc.ForwardSetState(SCE_MATLAB_DEFAULT); transpose = true; } else if(sc.ch == '.' && sc.chNext == '.') { - // we werent an operator, but a '...' + // we werent an operator, but a '...' sc.ChangeState(SCE_MATLAB_COMMENT); transpose = false; } else { @@ -165,7 +165,7 @@ static void ColouriseMatlabOctaveDoc( // end or start of a nested a block comment? if( IsCommentChar(sc.ch) && sc.chNext == '}' && nonSpaceColumn == column) { if(commentDepth > 0) commentDepth --; - + curLine = styler.GetLine(sc.currentPos); styler.SetLineState(curLine, commentDepth); sc.Forward(); diff --git a/ext/scintilla/lexers/LexMySQL.cxx b/ext/scintilla/lexers/LexMySQL.cxx index 87f537f83..15afcdc1e 100644 --- a/ext/scintilla/lexers/LexMySQL.cxx +++ b/ext/scintilla/lexers/LexMySQL.cxx @@ -331,7 +331,7 @@ static bool IsStreamCommentStyle(int style) * Code copied from StyleContext and modified to work here. Should go into Accessor as a * companion to Match()... */ -bool MatchIgnoreCase(Accessor &styler, Sci_Position currentPos, const char *s) +static bool MatchIgnoreCase(Accessor &styler, Sci_Position currentPos, const char *s) { for (Sci_Position n = 0; *s; n++) { @@ -362,7 +362,7 @@ static void FoldMySQLDoc(Sci_PositionU startPos, Sci_Position length, int initSt int styleNext = styler.StyleAt(startPos); int style = initStyle; int activeState = (style == SCE_MYSQL_HIDDENCOMMAND) ? HIDDENCOMMAND_STATE : style & HIDDENCOMMAND_STATE; - + bool endPending = false; bool whenPending = false; bool elseIfPending = false; @@ -375,11 +375,11 @@ static void FoldMySQLDoc(Sci_PositionU startPos, Sci_Position length, int initSt style = styleNext; styleNext = styler.StyleAt(i + 1); activeState = (style == SCE_MYSQL_HIDDENCOMMAND) ? HIDDENCOMMAND_STATE : style & HIDDENCOMMAND_STATE; - + char currentChar = nextChar; nextChar = styler.SafeGetCharAt(i + 1); bool atEOL = (currentChar == '\r' && nextChar != '\n') || (currentChar == '\n'); - + switch (MASKACTIVE(style)) { case SCE_MYSQL_COMMENT: @@ -392,7 +392,7 @@ static void FoldMySQLDoc(Sci_PositionU startPos, Sci_Position length, int initSt break; case SCE_MYSQL_COMMENTLINE: if (foldComment) - { + { // Not really a standard, but we add support for single line comments // with special curly braces syntax as foldable comments too. // MySQL needs -- comments to be followed by space or control char @@ -500,12 +500,12 @@ static void FoldMySQLDoc(Sci_PositionU startPos, Sci_Position length, int initSt } } } - + // Keep the current end state for the next round. endPending = endFound; } break; - + default: if (!isspacechar(currentChar) && endPending) { @@ -547,7 +547,7 @@ static void FoldMySQLDoc(Sci_PositionU startPos, Sci_Position length, int initSt lev |= SC_FOLDLEVELHEADERFLAG; if (lev != styler.LevelAt(lineCurrent)) styler.SetLevel(lineCurrent, lev); - + lineCurrent++; levelCurrent = levelNext; visibleChars = 0; diff --git a/ext/scintilla/lexers/LexOScript.cxx b/ext/scintilla/lexers/LexOScript.cxx index 55e57bdff..899881d70 100644 --- a/ext/scintilla/lexers/LexOScript.cxx +++ b/ext/scintilla/lexers/LexOScript.cxx @@ -205,12 +205,12 @@ static void ColouriseOScriptDoc(Sci_PositionU startPos, Sci_Position length, bool isFirstToken = true; // It starts with true at the beginning of a line and changes to false as // soon as the first identifier on the line is passed by. - bool isFirstIdentifier = true; + bool isFirstIdentifier = true; // It becomes false when #ifdef DOC (the preprocessor directive often // used to start a documentation comment) is encountered and remain false // until the end of the documentation block is not detected. This is done // by checking for the complementary #endif preprocessor directive. - bool endDocComment = false; + bool endDocComment = false; for (; sc.More(); sc.Forward()) { diff --git a/ext/scintilla/lexers/LexPB.cxx b/ext/scintilla/lexers/LexPB.cxx index 73ad6214c..e967fd825 100644 --- a/ext/scintilla/lexers/LexPB.cxx +++ b/ext/scintilla/lexers/LexPB.cxx @@ -70,7 +70,7 @@ static inline bool IsAWordStart(const int ch) return (ch < 0x80) && (isalnum(ch) || ch == '_'); } -bool MatchUpperCase(Accessor &styler, Sci_Position pos, const char *s) //Same as styler.Match() but uppercase comparison (a-z,A-Z and space only) +static bool MatchUpperCase(Accessor &styler, Sci_Position pos, const char *s) //Same as styler.Match() but uppercase comparison (a-z,A-Z and space only) { char ch; for (Sci_Position i=0; *s; i++) diff --git a/ext/scintilla/lexers/LexPO.cxx b/ext/scintilla/lexers/LexPO.cxx index fce5456de..cd33965c9 100644 --- a/ext/scintilla/lexers/LexPO.cxx +++ b/ext/scintilla/lexers/LexPO.cxx @@ -41,7 +41,7 @@ static void ColourisePODoc(Sci_PositionU startPos, Sci_Position length, int init Sci_Position curLine = styler.GetLine(startPos); // the line state holds the last state on or before the line that isn't the default style int curLineState = curLine > 0 ? styler.GetLineState(curLine - 1) : SCE_PO_DEFAULT; - + for (; sc.More(); sc.Forward()) { // whether we should leave a state switch (sc.state) { @@ -57,19 +57,19 @@ static void ColourisePODoc(Sci_PositionU startPos, Sci_Position length, int init // on its own like a keyword rather than changing the whole flags style sc.ChangeState(SCE_PO_FUZZY); break; - + case SCE_PO_MSGCTXT: case SCE_PO_MSGID: case SCE_PO_MSGSTR: if (isspacechar(sc.ch)) sc.SetState(SCE_PO_DEFAULT); break; - + case SCE_PO_ERROR: if (sc.atLineEnd) sc.SetState(SCE_PO_DEFAULT); break; - + case SCE_PO_MSGCTXT_TEXT: case SCE_PO_MSGID_TEXT: case SCE_PO_MSGSTR_TEXT: @@ -92,7 +92,7 @@ static void ColourisePODoc(Sci_PositionU startPos, Sci_Position length, int init } break; } - + // whether we should enter a new state if (sc.state == SCE_PO_DEFAULT) { // forward to the first non-white character on the line @@ -103,11 +103,11 @@ static void ColourisePODoc(Sci_PositionU startPos, Sci_Position length, int init // and anyway the styling don't use line state for comments if (curLineState == SCE_PO_COMMENT) curLineState = SCE_PO_DEFAULT; - + while (sc.More() && ! sc.atLineEnd && isspacechar(sc.ch)) sc.Forward(); } - + if (atLineStart && sc.ch == '#') { if (sc.chNext == '.') sc.SetState(SCE_PO_PROGRAMMER_COMMENT); @@ -134,11 +134,11 @@ static void ColourisePODoc(Sci_PositionU startPos, Sci_Position length, int init sc.SetState(SCE_PO_ERROR); } else if (! isspacechar(sc.ch)) sc.SetState(SCE_PO_ERROR); - + if (sc.state != SCE_PO_DEFAULT) curLineState = sc.state; } - + if (sc.atLineEnd) { // Update the line state, so it can be seen by next line curLine = styler.GetLine(sc.currentPos); @@ -163,7 +163,7 @@ static void FoldPODoc(Sci_PositionU startPos, Sci_Position length, int, WordList return; bool foldCompact = styler.GetPropertyInt("fold.compact") != 0; bool foldComment = styler.GetPropertyInt("fold.comment") != 0; - + Sci_PositionU endPos = startPos + length; Sci_Position curLine = styler.GetLine(startPos); int lineState = styler.GetLineState(curLine); @@ -172,17 +172,17 @@ static void FoldPODoc(Sci_PositionU startPos, Sci_Position length, int, WordList int nextLevel; int visible = 0; int chNext = styler[startPos]; - + for (Sci_PositionU i = startPos; i < endPos; i++) { int ch = chNext; chNext = styler.SafeGetCharAt(i+1); - + if (! isspacechar(ch)) { visible++; } else if ((ch == '\r' && chNext != '\n') || ch == '\n' || i+1 >= endPos) { int lvl = level; Sci_Position nextLine = curLine + 1; - + nextLineState = styler.GetLineState(nextLine); if ((lineState != SCE_PO_COMMENT || foldComment) && nextLineState == lineState && @@ -190,14 +190,14 @@ static void FoldPODoc(Sci_PositionU startPos, Sci_Position length, int, WordList nextLevel = SC_FOLDLEVELBASE + 1; else nextLevel = SC_FOLDLEVELBASE; - + if (nextLevel > level) lvl |= SC_FOLDLEVELHEADERFLAG; if (visible == 0 && foldCompact) lvl |= SC_FOLDLEVELWHITEFLAG; - + styler.SetLevel(curLine, lvl); - + lineState = nextLineState; curLine = nextLine; level = nextLevel; diff --git a/ext/scintilla/lexers/LexPerl.cxx b/ext/scintilla/lexers/LexPerl.cxx index 84088d379..4e020cce8 100644 --- a/ext/scintilla/lexers/LexPerl.cxx +++ b/ext/scintilla/lexers/LexPerl.cxx @@ -52,10 +52,10 @@ using namespace Scintilla; #define HERE_DELIM_MAX 256 // maximum length of HERE doc delimiter -#define PERLNUM_BINARY 1 // order is significant: 1-4 cannot have a dot -#define PERLNUM_HEX 2 -#define PERLNUM_OCTAL 3 -#define PERLNUM_FLOAT_EXP 4 // exponent part only +#define PERLNUM_BINARY 1 // order is significant: 1-3 cannot have a dot +#define PERLNUM_OCTAL 2 +#define PERLNUM_FLOAT_EXP 3 // exponent part only +#define PERLNUM_HEX 4 // may be a hex float #define PERLNUM_DECIMAL 5 // 1-5 are numbers; 6-7 are strings #define PERLNUM_VECTOR 6 #define PERLNUM_V_VECTOR 7 @@ -65,6 +65,12 @@ using namespace Scintilla; #define BACK_OPERATOR 1 // whitespace/comments are insignificant #define BACK_KEYWORD 2 // operators/keywords are needed for disambiguation +#define SUB_BEGIN 0 // states for subroutine prototype scan: +#define SUB_HAS_PROTO 1 // only 'prototype' attribute allows prototypes +#define SUB_HAS_ATTRIB 2 // other attributes can exist leftward +#define SUB_HAS_MODULE 3 // sub name can have a ::identifier part +#define SUB_HAS_SUB 4 // 'sub' keyword + // all interpolated styles are different from their parent styles by a constant difference // we also assume SCE_PL_STRING_VAR is the interpolated style with the smallest value #define INTERPOLATE_SHIFT (SCE_PL_STRING_VAR - SCE_PL_STRING) @@ -105,9 +111,11 @@ static int disambiguateBareword(LexAccessor &styler, Sci_PositionU bk, Sci_Posit // &bareword: subroutine call || styler.Match(bk - 1, "->") // ->bareword: part of variable spec + || styler.Match(bk - 1, "::") + // ::bareword: part of module spec || styler.Match(bk - 2, "sub")) { - // sub bareword: subroutine declaration - // (implied BACK_KEYWORD, no keywords end in 'sub'!) + // sub bareword: subroutine declaration + // (implied BACK_KEYWORD, no keywords end in 'sub'!) result |= 1; } // next, scan forward after word past tab/spaces only; @@ -121,7 +129,7 @@ static int disambiguateBareword(LexAccessor &styler, Sci_PositionU bk, Sci_Posit if ((ch == '}' && brace) // {bareword}: variable spec || styler.Match(fw, "=>")) { - // [{(, bareword=>: hash literal + // [{(, bareword=>: hash literal result |= 2; } } @@ -136,6 +144,22 @@ static void skipWhitespaceComment(LexAccessor &styler, Sci_PositionU &p) { p--; } +static int findPrevLexeme(LexAccessor &styler, Sci_PositionU &bk, int &style) { + // scan backward past whitespace and comments to find a lexeme + skipWhitespaceComment(styler, bk); + if (bk == 0) + return 0; + int sz = 1; + style = styler.StyleAt(bk); + while (bk > 0) { // find extent of lexeme + if (styler.StyleAt(bk - 1) == style) { + bk--; sz++; + } else + break; + } + return sz; +} + static int styleBeforeBracePair(LexAccessor &styler, Sci_PositionU bk) { // backtrack to find open '{' corresponding to a '}', balanced // return significant style to be tested for '/' disambiguation @@ -214,20 +238,59 @@ static int podLineScan(LexAccessor &styler, Sci_PositionU &pos, Sci_PositionU en static bool styleCheckSubPrototype(LexAccessor &styler, Sci_PositionU bk) { // backtrack to identify if we're starting a subroutine prototype - // we also need to ignore whitespace/comments: - // 'sub' [whitespace|comment] [whitespace|comment] + // we also need to ignore whitespace/comments, format is like: + // sub abc::pqr :const :prototype(...) + // lexemes are tested in pairs, e.g. '::'+'pqr', ':'+'const', etc. + // and a state machine generates legal subroutine syntax matches styler.Flush(); - skipWhitespaceComment(styler, bk); - if (bk == 0 || styler.StyleAt(bk) != SCE_PL_IDENTIFIER) // check identifier - return false; - while (bk > 0 && (styler.StyleAt(bk) == SCE_PL_IDENTIFIER)) { - bk--; - } - skipWhitespaceComment(styler, bk); - if (bk < 2 || styler.StyleAt(bk) != SCE_PL_WORD // check "sub" keyword - || !styler.Match(bk - 2, "sub")) // assume suffix is unique! - return false; - return true; + int state = SUB_BEGIN; + do { + // find two lexemes, lexeme 2 follows lexeme 1 + int style2 = SCE_PL_DEFAULT; + Sci_PositionU pos2 = bk; + int len2 = findPrevLexeme(styler, pos2, style2); + int style1 = SCE_PL_DEFAULT; + Sci_PositionU pos1 = pos2; + if (pos1 > 0) pos1--; + int len1 = findPrevLexeme(styler, pos1, style1); + if (len1 == 0 || len2 == 0) // lexeme pair must exist + break; + + // match parts of syntax, if invalid subroutine syntax, break off + if (style1 == SCE_PL_OPERATOR && len1 == 1 && + styler.SafeGetCharAt(pos1) == ':') { // ':' + if (style2 == SCE_PL_IDENTIFIER || style2 == SCE_PL_WORD) { + if (len2 == 9 && styler.Match(pos2, "prototype")) { // ':' 'prototype' + if (state == SUB_BEGIN) { + state = SUB_HAS_PROTO; + } else + break; + } else { // ':' + if (state == SUB_HAS_PROTO || state == SUB_HAS_ATTRIB) { + state = SUB_HAS_ATTRIB; + } else + break; + } + } else + break; + } else if (style1 == SCE_PL_OPERATOR && len1 == 2 && + styler.Match(pos1, "::")) { // '::' + if (style2 == SCE_PL_IDENTIFIER) { // '::' + state = SUB_HAS_MODULE; + } else + break; + } else if (style1 == SCE_PL_WORD && len1 == 3 && + styler.Match(pos1, "sub")) { // 'sub' + if (style2 == SCE_PL_IDENTIFIER) { // 'sub' + state = SUB_HAS_SUB; + } else + break; + } else + break; + bk = pos1; // set position for finding next lexeme pair + if (bk > 0) bk--; + } while (state != SUB_HAS_SUB); + return (state == SUB_HAS_SUB); } static int actualNumStyle(int numberStyle) { @@ -537,7 +600,8 @@ void SCI_METHOD LexerPerl::Lex(Sci_PositionU startPos, Sci_Position length, int CharacterSet &setPOD = setModifiers; CharacterSet setNonHereDoc(CharacterSet::setDigits, "=$@"); CharacterSet setHereDocDelim(CharacterSet::setAlphaNum, "_"); - CharacterSet setSubPrototype(CharacterSet::setNone, "\\[$@%&*+];"); + CharacterSet setSubPrototype(CharacterSet::setNone, "\\[$@%&*+];_ \t"); + CharacterSet setRepetition(CharacterSet::setDigits, ")\"'"); // for format identifiers CharacterSet setFormatStart(CharacterSet::setAlpha, "_="); CharacterSet &setFormat = setHereDocDelim; @@ -555,13 +619,12 @@ void SCI_METHOD LexerPerl::Lex(Sci_PositionU startPos, Sci_Position length, int int Quote; // the char after '<<' bool Quoted; // true if Quote in ('\'','"','`') int DelimiterLength; // strlen(Delimiter) - char *Delimiter; // the Delimiter, 256: sizeof PL_tokenbuf + char Delimiter[HERE_DELIM_MAX]; // the Delimiter HereDocCls() { State = 0; Quote = 0; Quoted = false; DelimiterLength = 0; - Delimiter = new char[HERE_DELIM_MAX]; Delimiter[0] = '\0'; } void Append(int ch) { @@ -569,7 +632,6 @@ void SCI_METHOD LexerPerl::Lex(Sci_PositionU startPos, Sci_Position length, int Delimiter[DelimiterLength] = '\0'; } ~HereDocCls() { - delete []Delimiter; } }; HereDocCls HereDoc; // TODO: FIFO for stacked here-docs @@ -762,6 +824,14 @@ void SCI_METHOD LexerPerl::Lex(Sci_PositionU startPos, Sci_Position length, int break; } // number then dot (go through) + } else if (numState == PERLNUM_HEX) { + if (dotCount <= 1 && IsADigit(sc.chNext, 16)) { + break; // hex with one dot is a hex float + } else { + sc.SetState(SCE_PL_OPERATOR); + break; + } + // hex then dot (go through) } else if (IsADigit(sc.chNext)) // vectors break; // vector then dot (go through) @@ -780,8 +850,15 @@ void SCI_METHOD LexerPerl::Lex(Sci_PositionU startPos, Sci_Position length, int break; // number then word (go through) } else if (numState == PERLNUM_HEX) { - if (IsADigit(sc.ch, 16)) + if (sc.ch == 'P' || sc.ch == 'p') { // hex float exponent, sign + numState = PERLNUM_FLOAT_EXP; + if (sc.chNext == '+' || sc.chNext == '-') { + sc.Forward(); + } + break; + } else if (IsADigit(sc.ch, 16)) break; + // hex or hex float then word (go through) } else if (numState == PERLNUM_VECTOR || numState == PERLNUM_V_VECTOR) { if (IsADigit(sc.ch)) // vector break; @@ -1265,7 +1342,7 @@ void SCI_METHOD LexerPerl::Lex(Sci_PositionU startPos, Sci_Position length, int fw++; } else if (sc.ch == 'x' && (sc.chNext == '=' || // repetition !setWord.Contains(sc.chNext) || - (IsADigit(sc.chPrev) && IsADigit(sc.chNext)))) { + (setRepetition.Contains(sc.chPrev) && IsADigit(sc.chNext)))) { sc.ChangeState(SCE_PL_OPERATOR); } // if potentially a keyword, scan forward and grab word, then check @@ -1438,7 +1515,10 @@ void SCI_METHOD LexerPerl::Lex(Sci_PositionU startPos, Sci_Position length, int } backFlag = BACK_NONE; if (isHereDoc) { // handle '<<', HERE doc - if (preferRE) { + if (sc.Match("<<>>")) { // double-diamond operator (5.22) + sc.SetState(SCE_PL_OPERATOR); + sc.Forward(3); + } else if (preferRE) { sc.SetState(SCE_PL_HERE_DELIM); HereDoc.State = 0; } else { // << operator diff --git a/ext/scintilla/lexers/LexRust.cxx b/ext/scintilla/lexers/LexRust.cxx index 4877abf74..601eaf2cc 100644 --- a/ext/scintilla/lexers/LexRust.cxx +++ b/ext/scintilla/lexers/LexRust.cxx @@ -287,7 +287,7 @@ static void ScanNumber(Accessor& styler, Sci_Position& pos) { } else if (!error) { /* If there's a period, it's a floating point literal unless it's * followed by an identifier (meaning this is a method call, e.g. - * `1.foo()`) or another period, in which case it's a range (e.g. 1..2) + * `1.foo()`) or another period, in which case it's a range (e.g. 1..2) */ n = styler.SafeGetCharAt(pos + 1, '\0'); if (c == '.' && !(IsIdentifierStart(n) || n == '.')) { @@ -308,7 +308,7 @@ static void ScanNumber(Accessor& styler, Sci_Position& pos) { /* It is invalid to have no digits in the exponent. */ error |= !ScanDigits(styler, pos, 10); } - + /* Scan the floating point suffix. */ c = styler.SafeGetCharAt(pos, '\0'); if (c == 'f') { @@ -620,7 +620,7 @@ static void ResumeRawString(Accessor &styler, Sci_Position& pos, Sci_Position ma } else if (pos >= max) { break; } else { - if (ascii_only && !IsASCII((char)c)) + if (ascii_only && !IsASCII((char)c)) break; pos++; } diff --git a/ext/scintilla/lexers/LexSML.cxx b/ext/scintilla/lexers/LexSML.cxx index e08303790..37dcdd411 100644 --- a/ext/scintilla/lexers/LexSML.cxx +++ b/ext/scintilla/lexers/LexSML.cxx @@ -33,7 +33,7 @@ inline int issmld(int c) {return isdigit(c) || c == '_';} using namespace Scintilla; #endif -void ColouriseSMLDoc( +static void ColouriseSMLDoc( Sci_PositionU startPos, Sci_Position length, int initStyle, WordList *keywordlists[], @@ -205,7 +205,7 @@ void ColouriseSMLDoc( sc.Complete(); } -void FoldSMLDoc( +static void FoldSMLDoc( Sci_PositionU, Sci_Position, int, WordList *[], diff --git a/ext/scintilla/lexers/LexSQL.cxx b/ext/scintilla/lexers/LexSQL.cxx index 442c3d453..1320baec6 100644 --- a/ext/scintilla/lexers/LexSQL.cxx +++ b/ext/scintilla/lexers/LexSQL.cxx @@ -567,8 +567,8 @@ void SCI_METHOD LexerSQL::Lex(Sci_PositionU startPos, Sci_Position length, int i break; } } - - char qComplement = 0x00; + + char qComplement = 0x00; if (qOperator == '<') { qComplement = '>'; @@ -580,8 +580,8 @@ void SCI_METHOD LexerSQL::Lex(Sci_PositionU startPos, Sci_Position length, int i qComplement = ']'; } else { qComplement = qOperator; - } - + } + if (sc.Match(qComplement, '\'')) { sc.Forward(); sc.ForwardSetState(SCE_SQL_DEFAULT); @@ -592,7 +592,7 @@ void SCI_METHOD LexerSQL::Lex(Sci_PositionU startPos, Sci_Position length, int i // Determine if a new state should be entered. if (sc.state == SCE_SQL_DEFAULT) { if (sc.Match('q', '\'') || sc.Match('Q', '\'')) { - sc.SetState(SCE_SQL_QOPERATOR); + sc.SetState(SCE_SQL_QOPERATOR); sc.Forward(); } else if (IsADigit(sc.ch) || (sc.ch == '.' && IsADigit(sc.chNext)) || ((sc.ch == '-' || sc.ch == '+') && IsADigit(sc.chNext) && !IsADigit(sc.chPrev))) { diff --git a/ext/scintilla/lexers/LexTCMD.cxx b/ext/scintilla/lexers/LexTCMD.cxx index c4a14fd98..59b2d7cf4 100644 --- a/ext/scintilla/lexers/LexTCMD.cxx +++ b/ext/scintilla/lexers/LexTCMD.cxx @@ -52,7 +52,7 @@ static unsigned int GetBatchVarLen( char *wordBuffer ) { int nLength = 0; if ( wordBuffer[0] == '%' ) { - + if ( wordBuffer[1] == '~' ) nLength = 2; else if (( wordBuffer[1] == '%' ) && ( wordBuffer[2] == '~' )) @@ -244,7 +244,7 @@ static void ColouriseTCMDLine( char *lineBuffer, Sci_PositionU lengthLine, Sci_P if ((CompareCaseInsensitive(sKeywordBuffer, "echo") == 0) || (CompareCaseInsensitive(sKeywordBuffer, "echos") == 0) || (CompareCaseInsensitive(sKeywordBuffer, "echoerr") == 0) || - (CompareCaseInsensitive(sKeywordBuffer, "echoserr") == 0) || + (CompareCaseInsensitive(sKeywordBuffer, "echoserr") == 0) || (CompareCaseInsensitive(sKeywordBuffer, "cd") == 0) || (CompareCaseInsensitive(sKeywordBuffer, "path") == 0) || (CompareCaseInsensitive(sKeywordBuffer, "prompt") == 0)) { diff --git a/ext/scintilla/lexers/LexVisualProlog.cxx b/ext/scintilla/lexers/LexVisualProlog.cxx index b28d1c5b0..e836182d6 100644 --- a/ext/scintilla/lexers/LexVisualProlog.cxx +++ b/ext/scintilla/lexers/LexVisualProlog.cxx @@ -162,6 +162,11 @@ static bool isAlphaNum(int ch){ return (ccLu == cc || ccLl == cc || ccLt == cc || ccLm == cc || ccLo == cc || ccNd == cc || ccNl == cc || ccNo == cc); } +static bool isStringVerbatimOpenClose(int ch){ + CharacterCategory cc = CategoriseCharacter(ch); + return (ccPc <= cc && cc <= ccSo); +} + static bool isIdChar(int ch){ return ('_') == ch || isAlphaNum(ch); } @@ -198,11 +203,11 @@ static bool isOpenStringVerbatim(int next, int &closingQuote){ case L';': return false; default: - if (isAlphaNum(next)) { - return false; - } else { + if (isStringVerbatimOpenClose(next)) { closingQuote = next; return true; + } else { + return false; } } } @@ -247,7 +252,7 @@ static void forwardEscapeLiteral(StyleContext &sc, int EscapeState) { void SCI_METHOD LexerVisualProlog::Lex(Sci_PositionU startPos, Sci_Position length, int initStyle, IDocument *pAccess) { LexAccessor styler(pAccess); CharacterSet setDoxygen(CharacterSet::setAlpha, ""); - CharacterSet setNumber(CharacterSet::setNone, "+-.0123456789abcdefABCDEFxoXO"); + CharacterSet setNumber(CharacterSet::setNone, "0123456789abcdefABCDEFxoXO"); StyleContext sc(startPos, length, initStyle, styler, 0x7f); @@ -273,7 +278,7 @@ void SCI_METHOD LexerVisualProlog::Lex(Sci_PositionU startPos, Sci_Position leng break; case SCE_VISUALPROLOG_NUMBER: // We accept almost anything because of hex. and number suffixes - if (!(setNumber.Contains(sc.ch))) { + if (!(setNumber.Contains(sc.ch)) || (sc.Match('.') && IsADigit(sc.chNext))) { sc.SetState(SCE_VISUALPROLOG_DEFAULT); } break; @@ -396,7 +401,7 @@ void SCI_METHOD LexerVisualProlog::Lex(Sci_PositionU startPos, Sci_Position leng if (sc.atLineEnd) { // Update the line state, so it can be seen by next line int lineState = 0; - if (SCE_VISUALPROLOG_STRING_VERBATIM_EOL == sc.state) { + if (SCE_VISUALPROLOG_STRING_VERBATIM_EOL == sc.state) { lineState = closingQuote; } else if (SCE_VISUALPROLOG_COMMENT_BLOCK == sc.state) { lineState = nestLevel; diff --git a/ext/scintilla/src/CellBuffer.cxx b/ext/scintilla/src/CellBuffer.cxx index e9f87796b..653feb74c 100644 --- a/ext/scintilla/src/CellBuffer.cxx +++ b/ext/scintilla/src/CellBuffer.cxx @@ -496,6 +496,25 @@ void CellBuffer::SetLineEndTypes(int utf8LineEnds_) { } } +bool CellBuffer::ContainsLineEnd(const char *s, int length) const { + unsigned char chBeforePrev = 0; + unsigned char chPrev = 0; + for (int i = 0; i < length; i++) { + const unsigned char ch = s[i]; + if ((ch == '\r') || (ch == '\n')) { + return true; + } else if (utf8LineEnds) { + unsigned char back3[3] = { chBeforePrev, chPrev, ch }; + if (UTF8IsSeparator(back3) || UTF8IsNEL(back3 + 1)) { + return true; + } + } + chBeforePrev = chPrev; + chPrev = ch; + } + return false; +} + void CellBuffer::SetPerLine(PerLine *pl) { lv.SetPerLine(pl); } diff --git a/ext/scintilla/src/CellBuffer.h b/ext/scintilla/src/CellBuffer.h index cb81a7db4..a5152024f 100644 --- a/ext/scintilla/src/CellBuffer.h +++ b/ext/scintilla/src/CellBuffer.h @@ -177,6 +177,7 @@ public: void Allocate(int newSize); int GetLineEndTypes() const { return utf8LineEnds; } void SetLineEndTypes(int utf8LineEnds_); + bool ContainsLineEnd(const char *s, int length) const; void SetPerLine(PerLine *pl); int Lines() const; int LineStart(int line) const; diff --git a/ext/scintilla/src/Document.cxx b/ext/scintilla/src/Document.cxx index b955be1e1..bea6a3e3c 100644 --- a/ext/scintilla/src/Document.cxx +++ b/ext/scintilla/src/Document.cxx @@ -109,6 +109,7 @@ Document::Document() { useTabs = true; tabIndents = true; backspaceUnindents = false; + durationStyleOneLine = 0.00001; matchesValid = false; regex = 0; @@ -270,7 +271,7 @@ void Document::TentativeUndo() { bool endSavePoint = cb.IsSavePoint(); if (startSavePoint != endSavePoint) NotifySavePoint(endSavePoint); - + cb.TentativeCommit(); } enteredModification--; @@ -1276,7 +1277,7 @@ int Document::SetLineIndentation(int line, int indent) { int indentPos = GetLineIndentPosition(line); UndoGroup ug(this); DeleteChars(thisLineStart, indentPos - thisLineStart); - return thisLineStart + InsertString(thisLineStart, linebuf.c_str(), + return thisLineStart + InsertString(thisLineStart, linebuf.c_str(), static_cast(linebuf.length())); } else { return GetLineIndentPosition(line); @@ -1892,6 +1893,33 @@ void Document::EnsureStyledTo(int pos) { } } +void Document::StyleToAdjustingLineDuration(int pos) { + // Place bounds on the duration used to avoid glitches spiking it + // and so causing slow styling or non-responsive scrolling + const double minDurationOneLine = 0.000001; + const double maxDurationOneLine = 0.0001; + + // Alpha value for exponential smoothing. + // Most recent value contributes 25% to smoothed value. + const double alpha = 0.25; + + const Sci_Position lineFirst = LineFromPosition(GetEndStyled()); + ElapsedTime etStyling; + EnsureStyledTo(pos); + const double durationStyling = etStyling.Duration(); + const Sci_Position lineLast = LineFromPosition(GetEndStyled()); + if (lineLast >= lineFirst + 8) { + // Only adjust for styling multiple lines to avoid instability + const double durationOneLine = durationStyling / (lineLast - lineFirst); + durationStyleOneLine = alpha * durationOneLine + (1.0 - alpha) * durationStyleOneLine; + if (durationStyleOneLine < minDurationOneLine) { + durationStyleOneLine = minDurationOneLine; + } else if (durationStyleOneLine > maxDurationOneLine) { + durationStyleOneLine = maxDurationOneLine; + } + } +} + void Document::LexerChanged() { // Tell the watchers the lexer has changed. for (std::vector::iterator it = watchers.begin(); it != watchers.end(); ++it) { @@ -2141,7 +2169,7 @@ int Document::WordPartRight(int pos) { return pos; } -bool IsLineEndChar(char c) { +static bool IsLineEndChar(char c) { return (c == '\n' || c == '\r'); } @@ -2187,7 +2215,7 @@ int Document::BraceMatch(int position, int /*maxReStyle*/) { char chSeek = BraceOpposite(chBrace); if (chSeek == '\0') return - 1; - char styBrace = static_cast(StyleAt(position)); + const int styBrace = StyleIndexAt(position); int direction = -1; if (chBrace == '(' || chBrace == '[' || chBrace == '{' || chBrace == '<') direction = 1; @@ -2195,7 +2223,7 @@ int Document::BraceMatch(int position, int /*maxReStyle*/) { position = NextPosition(position, direction); while ((position >= 0) && (position < Length())) { char chAtPos = CharAt(position); - char styAtPos = static_cast(StyleAt(position)); + const int styAtPos = StyleIndexAt(position); if ((position > GetEndStyled()) || (styAtPos == styBrace)) { if (chAtPos == chBrace) depth++; @@ -2526,10 +2554,10 @@ public: return doc != other.doc || position != other.position; } int Pos() const { - return position; + return position; } int PosRoundUp() const { - return position; + return position; } }; @@ -2626,7 +2654,7 @@ long Cxx11RegexFindText(Document *doc, int minPos, int maxPos, const char *s, std::wregex regexp; #if defined(__APPLE__) // Using a UTF-8 locale doesn't change to Unicode over a byte buffer so '.' - // is one byte not one character. + // is one byte not one character. // However, on OS X this makes wregex act as Unicode std::locale localeU("en_US.UTF-8"); regexp.imbue(localeU); diff --git a/ext/scintilla/src/Document.h b/ext/scintilla/src/Document.h index d0ca953bc..bf9117cbb 100644 --- a/ext/scintilla/src/Document.h +++ b/ext/scintilla/src/Document.h @@ -246,6 +246,7 @@ public: bool useTabs; bool tabIndents; bool backspaceUnindents; + double durationStyleOneLine; DecorationList decorations; @@ -272,6 +273,7 @@ public: Sci_Position SCI_METHOD LineFromPosition(Sci_Position pos) const; int ClampPositionIntoDocument(int pos) const; + bool ContainsLineEnd(const char *s, int length) const { return cb.ContainsLineEnd(s, length); } bool IsCrLf(int pos) const; int LenChar(int pos); bool InGoodUTF8(int pos, int &start, int &end) const; @@ -339,6 +341,7 @@ public: cb.GetCharRange(buffer, position, lengthRetrieve); } char SCI_METHOD StyleAt(Sci_Position position) const { return cb.StyleAt(position); } + int StyleIndexAt(Sci_Position position) const { return static_cast(cb.StyleAt(position)); } void GetStyleRange(unsigned char *buffer, int position, int lengthRetrieve) const { cb.GetStyleRange(buffer, position, lengthRetrieve); } @@ -375,7 +378,7 @@ public: struct CharacterExtracted { unsigned int character; unsigned int widthBytes; - CharacterExtracted(unsigned int character_, unsigned int widthBytes_) : + CharacterExtracted(unsigned int character_, unsigned int widthBytes_) : character(character_), widthBytes(widthBytes_) { } }; @@ -400,6 +403,7 @@ public: bool SCI_METHOD SetStyles(Sci_Position length, const char *styles); int GetEndStyled() const { return endStyled; } void EnsureStyledTo(int pos); + void StyleToAdjustingLineDuration(int pos); void LexerChanged(); int GetStyleClock() const { return styleClock; } void IncrementStyleClock(); @@ -425,7 +429,7 @@ public: void AnnotationSetStyles(int line, const unsigned char *styles); int AnnotationLines(int line) const; void AnnotationClearAll(); - + bool AddWatcher(DocWatcher *watcher, void *userData); bool RemoveWatcher(DocWatcher *watcher, void *userData); diff --git a/ext/scintilla/src/EditModel.h b/ext/scintilla/src/EditModel.h index bde14c03c..458209556 100644 --- a/ext/scintilla/src/EditModel.h +++ b/ext/scintilla/src/EditModel.h @@ -42,7 +42,7 @@ public: Selection sel; bool primarySelection; - enum IMEInteraction { imeWindowed, imeInline } imeInteraction; + enum IMEInteraction { imeWindowed, imeInline } imeInteraction; int foldFlags; ContractionState cs; diff --git a/ext/scintilla/src/EditView.cxx b/ext/scintilla/src/EditView.cxx index 9b68a835c..5acbd8cc4 100644 --- a/ext/scintilla/src/EditView.cxx +++ b/ext/scintilla/src/EditView.cxx @@ -48,7 +48,6 @@ #include "EditModel.h" #include "MarginView.h" #include "EditView.h" -#include "Editor.h" #ifdef SCI_NAMESPACE using namespace Scintilla; @@ -192,7 +191,6 @@ EditView::EditView() { tabArrowHeight = 4; customDrawTabArrow = NULL; customDrawWrapMarker = NULL; - editor = NULL; } EditView::~EditView() { @@ -293,7 +291,7 @@ void EditView::AllocateGraphics(const ViewStyle &vsDraw) { pixmapIndentGuideHighlight = Surface::Allocate(vsDraw.technology); } -const char *ControlCharacterString(unsigned char ch) { +static const char *ControlCharacterString(unsigned char ch) { const char *reps[] = { "NUL", "SOH", "STX", "ETX", "EOT", "ENQ", "ACK", "BEL", "BS", "HT", "LF", "VT", "FF", "CR", "SO", "SI", @@ -307,7 +305,7 @@ const char *ControlCharacterString(unsigned char ch) { } } -void DrawTabArrow(Surface *surface, PRectangle rcTab, int ymid) { +static void DrawTabArrow(Surface *surface, PRectangle rcTab, int ymid) { int ydiff = static_cast(rcTab.bottom - rcTab.top) / 2; int xhead = static_cast(rcTab.right) - 1 - ydiff; if (xhead <= rcTab.left) { @@ -378,14 +376,14 @@ void EditView::LayoutLine(const EditModel &model, int line, Surface *surface, co // See if chars, styles, indicators, are all the same bool allSame = true; // Check base line layout - char styleByte = 0; + int styleByte = 0; int numCharsInLine = 0; while (numCharsInLine < lineLength) { int charInDoc = numCharsInLine + posLineStart; char chDoc = model.pdoc->CharAt(charInDoc); - styleByte = model.pdoc->StyleAt(charInDoc); + styleByte = model.pdoc->StyleIndexAt(charInDoc); allSame = allSame && - (ll->styles[numCharsInLine] == static_cast(styleByte)); + (ll->styles[numCharsInLine] == styleByte); if (vstyle.styles[ll->styles[numCharsInLine]].caseForce == Style::caseMixed) allSame = allSame && (ll->chars[numCharsInLine] == chDoc); @@ -396,7 +394,7 @@ void EditView::LayoutLine(const EditModel &model, int line, Surface *surface, co allSame = allSame && (ll->chars[numCharsInLine] == static_cast(toupper(chDoc))); else { // Style::caseCamel - if ((model.pdoc->WordCharClass(ll->chars[numCharsInLine]) == CharClassify::ccWord) && + if ((model.pdoc->WordCharClass(ll->chars[numCharsInLine]) == CharClassify::ccWord) && ((numCharsInLine == 0) || (model.pdoc->WordCharClass(ll->chars[numCharsInLine - 1]) != CharClassify::ccWord))) { allSame = allSame && (ll->chars[numCharsInLine] == static_cast(toupper(chDoc))); } else { @@ -446,13 +444,13 @@ void EditView::LayoutLine(const EditModel &model, int line, Surface *surface, co else if (vstyle.styles[ll->styles[charInLine]].caseForce == Style::caseLower) ll->chars[charInLine] = static_cast(tolower(chDoc)); else if (vstyle.styles[ll->styles[charInLine]].caseForce == Style::caseCamel) { - if ((model.pdoc->WordCharClass(ll->chars[charInLine]) == CharClassify::ccWord) && + if ((model.pdoc->WordCharClass(ll->chars[charInLine]) == CharClassify::ccWord) && ((charInLine == 0) || (model.pdoc->WordCharClass(ll->chars[charInLine - 1]) != CharClassify::ccWord))) { ll->chars[charInLine] = static_cast(toupper(chDoc)); } else { ll->chars[charInLine] = static_cast(tolower(chDoc)); } - } + } } } ll->xHighlightGuide = 0; @@ -713,12 +711,14 @@ int EditView::StartEndDisplayLine(Surface *surface, const EditModel &model, int int posInLine = pos - posLineStart; if (posInLine <= ll->maxLineLength) { for (int subLine = 0; subLine < ll->lines; subLine++) { - if ((posInLine >= ll->LineStart(subLine)) && (posInLine <= ll->LineStart(subLine + 1))) { + if ((posInLine >= ll->LineStart(subLine)) && + (posInLine <= ll->LineStart(subLine + 1)) && + (posInLine <= ll->numCharsBeforeEOL)) { if (start) { posRet = ll->LineStart(subLine) + posLineStart; } else { if (subLine == ll->lines - 1) - posRet = ll->LineStart(subLine + 1) + posLineStart; + posRet = ll->numCharsBeforeEOL + posLineStart; else posRet = ll->LineStart(subLine + 1) + posLineStart - 1; } @@ -986,11 +986,10 @@ static void DrawIndicators(Surface *surface, const EditModel &model, const ViewS startPos = deco->rs.EndRun(startPos); } while ((startPos < posLineEnd) && (deco->rs.ValueAt(startPos))) { - int endPos = deco->rs.EndRun(startPos); - if (endPos > posLineEnd) - endPos = posLineEnd; + const Range rangeRun(deco->rs.StartRun(startPos), deco->rs.EndRun(startPos)); + const int endPos = std::min(rangeRun.end, posLineEnd); const bool hover = vsDraw.indicators[deco->indicator].IsDynamic() && - ((hoverIndicatorPos >= startPos) && (hoverIndicatorPos <= endPos)); + rangeRun.ContainsCharacter(hoverIndicatorPos); const int value = deco->rs.ValueAt(startPos); Indicator::DrawState drawState = hover ? Indicator::drawHover : Indicator::drawNormal; DrawIndicator(deco->indicator, startPos - posLineStart, endPos - posLineStart, @@ -1303,8 +1302,7 @@ void EditView::DrawBackground(Surface *surface, const EditModel &model, const Vi if (ts.representation) { if (ll->chars[i] == '\t') { // Tab display - if (drawWhitespaceBackground && - (!inIndentation || vsDraw.viewWhitespace == wsVisibleAlways)) + if (drawWhitespaceBackground && vsDraw.WhiteSpaceVisible(inIndentation)) textBack = vsDraw.whitespaceColours.back; } else { // Blob display @@ -1314,12 +1312,10 @@ void EditView::DrawBackground(Surface *surface, const EditModel &model, const Vi } else { // Normal text display surface->FillRectangle(rcSegment, textBack); - if (vsDraw.viewWhitespace != wsInvisible || - (inIndentation && vsDraw.viewIndentationGuides == ivReal)) { + if (vsDraw.viewWhitespace != wsInvisible) { for (int cpos = 0; cpos <= i - ts.start; cpos++) { if (ll->chars[cpos + ts.start] == ' ') { - if (drawWhitespaceBackground && - (!inIndentation || vsDraw.viewWhitespace == wsVisibleAlways)) { + if (drawWhitespaceBackground && vsDraw.WhiteSpaceVisible(inIndentation)) { PRectangle rcSpace( ll->positions[cpos + ts.start] + xStart - static_cast(subLineStart), rcSegment.top, @@ -1410,27 +1406,26 @@ static void DrawTranslucentLineState(Surface *surface, const EditModel &model, c if ((model.caret.active || vsDraw.alwaysShowCaretLineBackground) && vsDraw.showCaretLineBackground && ll->containsCaret) { SimpleAlphaRectangle(surface, rcLine, vsDraw.caretLineBackground, vsDraw.caretLineAlpha); } - int marks = model.pdoc->GetMark(line); - for (int markBit = 0; (markBit < 32) && marks; markBit++) { - if ((marks & 1) && (vsDraw.markers[markBit].markType == SC_MARK_BACKGROUND)) { - SimpleAlphaRectangle(surface, rcLine, vsDraw.markers[markBit].back, vsDraw.markers[markBit].alpha); - } else if ((marks & 1) && (vsDraw.markers[markBit].markType == SC_MARK_UNDERLINE)) { - PRectangle rcUnderline = rcLine; - rcUnderline.top = rcUnderline.bottom - 2; - SimpleAlphaRectangle(surface, rcUnderline, vsDraw.markers[markBit].back, vsDraw.markers[markBit].alpha); + const int marksOfLine = model.pdoc->GetMark(line); + int marksDrawnInText = marksOfLine & vsDraw.maskDrawInText; + for (int markBit = 0; (markBit < 32) && marksDrawnInText; markBit++) { + if (marksDrawnInText & 1) { + if (vsDraw.markers[markBit].markType == SC_MARK_BACKGROUND) { + SimpleAlphaRectangle(surface, rcLine, vsDraw.markers[markBit].back, vsDraw.markers[markBit].alpha); + } else if (vsDraw.markers[markBit].markType == SC_MARK_UNDERLINE) { + PRectangle rcUnderline = rcLine; + rcUnderline.top = rcUnderline.bottom - 2; + SimpleAlphaRectangle(surface, rcUnderline, vsDraw.markers[markBit].back, vsDraw.markers[markBit].alpha); + } } - marks >>= 1; + marksDrawnInText >>= 1; } - if (vsDraw.maskInLine) { - int marksMasked = model.pdoc->GetMark(line) & vsDraw.maskInLine; - if (marksMasked) { - for (int markBit = 0; (markBit < 32) && marksMasked; markBit++) { - if ((marksMasked & 1) && (vsDraw.markers[markBit].markType != SC_MARK_EMPTY)) { - SimpleAlphaRectangle(surface, rcLine, vsDraw.markers[markBit].back, vsDraw.markers[markBit].alpha); - } - marksMasked >>= 1; - } + int marksDrawnInLine = marksOfLine & vsDraw.maskInLine; + for (int markBit = 0; (markBit < 32) && marksDrawnInLine; markBit++) { + if (marksDrawnInLine & 1) { + SimpleAlphaRectangle(surface, rcLine, vsDraw.markers[markBit].back, vsDraw.markers[markBit].alpha); } + marksDrawnInLine >>= 1; } } @@ -1480,7 +1475,7 @@ void EditView::DrawForeground(Surface *surface, const EditModel &model, const Vi if (indicatorValue) { const Indicator &indicator = vsDraw.indicators[deco->indicator]; const bool hover = indicator.IsDynamic() && - ((model.hoverIndicatorPos >= ts.start + posLineStart) && + ((model.hoverIndicatorPos >= ts.start + posLineStart) && (model.hoverIndicatorPos <= ts.end() + posLineStart)); if (hover) { if (indicator.sacHover.style == INDIC_TEXTFORE) { @@ -1506,8 +1501,7 @@ void EditView::DrawForeground(Surface *surface, const EditModel &model, const Vi if (ll->chars[i] == '\t') { // Tab display if (phasesDraw == phasesOne) { - if (drawWhitespaceBackground && - (!inIndentation || vsDraw.viewWhitespace == wsVisibleAlways)) + if (drawWhitespaceBackground && vsDraw.WhiteSpaceVisible(inIndentation)) textBack = vsDraw.whitespaceColours.back; surface->FillRectangle(rcSegment, textBack); } @@ -1523,7 +1517,7 @@ void EditView::DrawForeground(Surface *surface, const EditModel &model, const Vi } } if (vsDraw.viewWhitespace != wsInvisible) { - if (!inIndentation || vsDraw.viewWhitespace == wsVisibleAlways) { + if (vsDraw.WhiteSpaceVisible(inIndentation)) { if (vsDraw.whitespaceColours.fore.isSet) textFore = vsDraw.whitespaceColours.fore; surface->PenColour(textFore); @@ -1571,10 +1565,9 @@ void EditView::DrawForeground(Surface *surface, const EditModel &model, const Vi if (vsDraw.viewWhitespace != wsInvisible) { if (vsDraw.whitespaceColours.fore.isSet) textFore = vsDraw.whitespaceColours.fore; - if (!inIndentation || vsDraw.viewWhitespace == wsVisibleAlways) { + if (vsDraw.WhiteSpaceVisible(inIndentation)) { XYPOSITION xmid = (ll->positions[cpos + ts.start] + ll->positions[cpos + ts.start + 1]) / 2; - if ((phasesDraw == phasesOne) && drawWhitespaceBackground && - (!inIndentation || vsDraw.viewWhitespace == wsVisibleAlways)) { + if ((phasesDraw == phasesOne) && drawWhitespaceBackground) { textBack = vsDraw.whitespaceColours.back; PRectangle rcSpace( ll->positions[cpos + ts.start] + xStart - static_cast(subLineStart), @@ -1583,7 +1576,8 @@ void EditView::DrawForeground(Surface *surface, const EditModel &model, const Vi rcSegment.bottom); surface->FillRectangle(rcSpace, textBack); } - PRectangle rcDot(xmid + xStart - static_cast(subLineStart), + const int halfDotWidth = vsDraw.whitespaceSize / 2; + PRectangle rcDot(xmid + xStart - halfDotWidth - static_cast(subLineStart), rcSegment.top + vsDraw.lineHeight / 2, 0.0f, 0.0f); rcDot.right = rcDot.left + vsDraw.whitespaceSize; rcDot.bottom = rcDot.top + vsDraw.whitespaceSize; @@ -1690,17 +1684,7 @@ void EditView::DrawLine(Surface *surface, const EditModel &model, const ViewStyl } // See if something overrides the line background color. - ColourOptional background = vsDraw.Background(model.pdoc->GetMark(line), model.caret.active, ll->containsCaret); - SCNotification scn = { 0 }; - scn.nmhdr.code = SCN_GETBKCOLOR; - scn.line = line; - scn.lParam = -1; - if (editor) - ((Editor*)editor)->NotifyParent(&scn); - if (scn.lParam != -1) { - background.Set(scn.lParam); - background.isSet = true; - } + const ColourOptional background = vsDraw.Background(model.pdoc->GetMark(line), model.caret.active, ll->containsCaret); const int posLineStart = model.pdoc->LineStart(line); @@ -1952,7 +1936,7 @@ void EditView::PaintText(Surface *surfaceWindow, const EditModel &model, PRectan // Space (3 space characters) between line numbers and text when printing. #define lineNumberPrintSpace " " -ColourDesired InvertedLight(ColourDesired orig) { +static ColourDesired InvertedLight(ColourDesired orig) { unsigned int r = orig.GetRed(); unsigned int g = orig.GetGreen(); unsigned int b = orig.GetBlue(); diff --git a/ext/scintilla/src/EditView.h b/ext/scintilla/src/EditView.h index 967ccd772..abb8835eb 100644 --- a/ext/scintilla/src/EditView.h +++ b/ext/scintilla/src/EditView.h @@ -77,7 +77,6 @@ public: Surface *pixmapLine; Surface *pixmapIndentGuide; Surface *pixmapIndentGuideHighlight; - void *editor; LineLayoutCache llc; PositionCache posCache; diff --git a/ext/scintilla/src/Editor.cxx b/ext/scintilla/src/Editor.cxx index 0e62d596f..a65f3aeb6 100644 --- a/ext/scintilla/src/Editor.cxx +++ b/ext/scintilla/src/Editor.cxx @@ -101,7 +101,6 @@ static inline bool IsAllSpacesOrTabs(const char *s, unsigned int len) { } Editor::Editor() { - view.editor = this; ctrlID = 0; stylesValid = false; @@ -174,6 +173,8 @@ Editor::Editor() { paintAbandonedByStyling = false; paintingAllText = false; willRedrawAll = false; + idleStyling = SC_IDLESTYLING_NONE; + needIdleStyling = false; modEventMask = SC_MODEVENTMASKALL; @@ -479,44 +480,48 @@ void Editor::Redraw() { } void Editor::RedrawSelMargin(int line, bool allAfter) { - bool abandonDraw = false; - if (!wMargin.GetID()) // Margin in main window so may need to abandon and retry - abandonDraw = AbandonPaint(); - if (!abandonDraw) { - if (vs.maskInLine) { - Redraw(); - } else { - PRectangle rcSelMargin = GetClientRectangle(); - rcSelMargin.right = rcSelMargin.left + vs.fixedColumnWidth; - if (line != -1) { - PRectangle rcLine = RectangleFromRange(Range(pdoc->LineStart(line)), 0); - - // Inflate line rectangle if there are image markers with height larger than line height - if (vs.largestMarkerHeight > vs.lineHeight) { - int delta = (vs.largestMarkerHeight - vs.lineHeight + 1) / 2; - rcLine.top -= delta; - rcLine.bottom += delta; - if (rcLine.top < rcSelMargin.top) - rcLine.top = rcSelMargin.top; - if (rcLine.bottom > rcSelMargin.bottom) - rcLine.bottom = rcSelMargin.bottom; - } - - rcSelMargin.top = rcLine.top; - if (!allAfter) - rcSelMargin.bottom = rcLine.bottom; - if (rcSelMargin.Empty()) - return; - } - if (wMargin.GetID()) { - Point ptOrigin = GetVisibleOriginInMain(); - rcSelMargin.Move(-ptOrigin.x, -ptOrigin.y); - wMargin.InvalidateRectangle(rcSelMargin); - } else { - wMain.InvalidateRectangle(rcSelMargin); - } + const bool markersInText = vs.maskInLine || vs.maskDrawInText; + if (!wMargin.GetID() || markersInText) { // May affect text area so may need to abandon and retry + if (AbandonPaint()) { + return; } } + if (wMargin.GetID() && markersInText) { + Redraw(); + return; + } + PRectangle rcMarkers = GetClientRectangle(); + if (!markersInText) { + // Normal case: just draw the margin + rcMarkers.right = rcMarkers.left + vs.fixedColumnWidth; + } + if (line != -1) { + PRectangle rcLine = RectangleFromRange(Range(pdoc->LineStart(line)), 0); + + // Inflate line rectangle if there are image markers with height larger than line height + if (vs.largestMarkerHeight > vs.lineHeight) { + int delta = (vs.largestMarkerHeight - vs.lineHeight + 1) / 2; + rcLine.top -= delta; + rcLine.bottom += delta; + if (rcLine.top < rcMarkers.top) + rcLine.top = rcMarkers.top; + if (rcLine.bottom > rcMarkers.bottom) + rcLine.bottom = rcMarkers.bottom; + } + + rcMarkers.top = rcLine.top; + if (!allAfter) + rcMarkers.bottom = rcLine.bottom; + if (rcMarkers.Empty()) + return; + } + if (wMargin.GetID()) { + Point ptOrigin = GetVisibleOriginInMain(); + rcMarkers.Move(-ptOrigin.x, -ptOrigin.y); + wMargin.InvalidateRectangle(rcMarkers); + } else { + wMain.InvalidateRectangle(rcMarkers); + } } PRectangle Editor::RectangleFromRange(Range r, int overlap) { @@ -759,7 +764,7 @@ bool Editor::RangeContainsProtected(int start, int end) const { end = t; } for (int pos = start; pos < end; pos++) { - if (vs.styles[pdoc->StyleAt(pos)].IsProtected()) + if (vs.styles[pdoc->StyleIndexAt(pos)].IsProtected()) return true; } } @@ -789,15 +794,15 @@ SelectionPosition Editor::MovePositionOutsideChar(SelectionPosition pos, int mov pos.SetPosition(posMoved); if (vs.ProtectionActive()) { if (moveDir > 0) { - if ((pos.Position() > 0) && vs.styles[pdoc->StyleAt(pos.Position() - 1)].IsProtected()) { + if ((pos.Position() > 0) && vs.styles[pdoc->StyleIndexAt(pos.Position() - 1)].IsProtected()) { while ((pos.Position() < pdoc->Length()) && - (vs.styles[pdoc->StyleAt(pos.Position())].IsProtected())) + (vs.styles[pdoc->StyleIndexAt(pos.Position())].IsProtected())) pos.Add(1); } } else if (moveDir < 0) { - if (vs.styles[pdoc->StyleAt(pos.Position())].IsProtected()) { + if (vs.styles[pdoc->StyleIndexAt(pos.Position())].IsProtected()) { while ((pos.Position() > 0) && - (vs.styles[pdoc->StyleAt(pos.Position() - 1)].IsProtected())) + (vs.styles[pdoc->StyleIndexAt(pos.Position() - 1)].IsProtected())) pos.Add(-1); } } @@ -916,7 +921,7 @@ void Editor::ScrollTo(int line, bool moveThumb) { SetTopLine(topLineNew); // Optimize by styling the view as this will invalidate any needed area // which could abort the initial paint if discovered later. - StyleToPositionInView(PositionAfterArea(GetClientRectangle())); + StyleAreaBounded(GetClientRectangle(), true); #ifndef UNDER_CE // Perform redraw rather than scroll if many lines would be redrawn anyway. if (performBlit) { @@ -1689,7 +1694,7 @@ void Editor::Paint(Surface *surfaceWindow, PRectangle rcArea) { paintAbandonedByStyling = false; - StyleToPositionInView(PositionAfterArea(rcArea)); + StyleAreaBounded(rcArea, false); PRectangle rcClient = GetClientRectangle(); //Platform::DebugPrintf("Client: (%3d,%3d) ... (%3d,%3d) %d\n", @@ -1951,6 +1956,8 @@ void Editor::AddCharUTF(const char *s, unsigned int len, bool treatAsDBCS) { void Editor::ClearBeforeTentativeStart() { // Make positions for the first composition string. + FilterSelections(); + UndoGroup ug(pdoc, (sel.Count() > 1) || !sel.Empty() || inOverstrike); for (size_t r = 0; r