diff --git a/Makefile.in b/Makefile.in index 57f68c1d66..2dc585df19 100644 --- a/Makefile.in +++ b/Makefile.in @@ -283,7 +283,12 @@ WXSCINTILLA_OBJECTS = \ wxscintilla_LexNsis.o \ wxscintilla_LexOpal.o \ wxscintilla_LexOScript.o \ - wxscintilla_LexOthers.o \ + wxscintilla_LexBatch.o \ + wxscintilla_LexDiff.o \ + wxscintilla_LexErrorList.o \ + wxscintilla_LexMake.o \ + wxscintilla_LexNull.o \ + wxscintilla_LexProps.o \ wxscintilla_LexPascal.o \ wxscintilla_LexPB.o \ wxscintilla_LexPerl.o \ @@ -15309,8 +15314,23 @@ wxscintilla_LexOpal.o: $(srcdir)/src/stc/scintilla/lexers/LexOpal.cxx wxscintilla_LexOScript.o: $(srcdir)/src/stc/scintilla/lexers/LexOScript.cxx $(CXXC) -c -o $@ $(WXSCINTILLA_CXXFLAGS) $(srcdir)/src/stc/scintilla/lexers/LexOScript.cxx -wxscintilla_LexOthers.o: $(srcdir)/src/stc/scintilla/lexers/LexOthers.cxx - $(CXXC) -c -o $@ $(WXSCINTILLA_CXXFLAGS) $(srcdir)/src/stc/scintilla/lexers/LexOthers.cxx +wxscintilla_LexBatch.o: $(srcdir)/src/stc/scintilla/lexers/LexBatch.cxx + $(CXXC) -c -o $@ $(WXSCINTILLA_CXXFLAGS) $(srcdir)/src/stc/scintilla/lexers/LexBatch.cxx + +wxscintilla_LexDiff.o: $(srcdir)/src/stc/scintilla/lexers/LexDiff.cxx + $(CXXC) -c -o $@ $(WXSCINTILLA_CXXFLAGS) $(srcdir)/src/stc/scintilla/lexers/LexDiff.cxx + +wxscintilla_LexErrorList.o: $(srcdir)/src/stc/scintilla/lexers/LexErrorList.cxx + $(CXXC) -c -o $@ $(WXSCINTILLA_CXXFLAGS) $(srcdir)/src/stc/scintilla/lexers/LexErrorList.cxx + +wxscintilla_LexMake.o: $(srcdir)/src/stc/scintilla/lexers/LexMake.cxx + $(CXXC) -c -o $@ $(WXSCINTILLA_CXXFLAGS) $(srcdir)/src/stc/scintilla/lexers/LexMake.cxx + +wxscintilla_LexNull.o: $(srcdir)/src/stc/scintilla/lexers/LexNull.cxx + $(CXXC) -c -o $@ $(WXSCINTILLA_CXXFLAGS) $(srcdir)/src/stc/scintilla/lexers/LexNull.cxx + +wxscintilla_LexProps.o: $(srcdir)/src/stc/scintilla/lexers/LexProps.cxx + $(CXXC) -c -o $@ $(WXSCINTILLA_CXXFLAGS) $(srcdir)/src/stc/scintilla/lexers/LexProps.cxx wxscintilla_LexPascal.o: $(srcdir)/src/stc/scintilla/lexers/LexPascal.cxx $(CXXC) -c -o $@ $(WXSCINTILLA_CXXFLAGS) $(srcdir)/src/stc/scintilla/lexers/LexPascal.cxx diff --git a/build/bakefiles/scintilla.bkl b/build/bakefiles/scintilla.bkl index 06d41a15b1..2ec61a919f 100644 --- a/build/bakefiles/scintilla.bkl +++ b/build/bakefiles/scintilla.bkl @@ -116,7 +116,6 @@ src/stc/scintilla/lexers/LexNsis.cxx src/stc/scintilla/lexers/LexOpal.cxx src/stc/scintilla/lexers/LexOScript.cxx - src/stc/scintilla/lexers/LexOthers.cxx src/stc/scintilla/lexers/LexPascal.cxx src/stc/scintilla/lexers/LexPB.cxx src/stc/scintilla/lexers/LexPerl.cxx diff --git a/include/wx/stc/stc.h b/include/wx/stc/stc.h index 0e74afce34..0f69df1c67 100644 --- a/include/wx/stc/stc.h +++ b/include/wx/stc/stc.h @@ -68,6 +68,7 @@ class WXDLLIMPEXP_FWD_CORE wxScrollBar; #define wxSTC_WS_INVISIBLE 0 #define wxSTC_WS_VISIBLEALWAYS 1 #define wxSTC_WS_VISIBLEAFTERINDENT 2 +#define wxSTC_WS_VISIBLEONLYININDENT 3 #define wxSTC_EOL_CRLF 0 #define wxSTC_EOL_CR 1 #define wxSTC_EOL_LF 2 @@ -158,6 +159,7 @@ class WXDLLIMPEXP_FWD_CORE wxScrollBar; #define wxSTC_CHARSET_MAC 77 #define wxSTC_CHARSET_OEM 255 #define wxSTC_CHARSET_RUSSIAN 204 +#define wxSTC_CHARSET_OEM866 866 #define wxSTC_CHARSET_CYRILLIC 1251 #define wxSTC_CHARSET_SHIFTJIS 128 #define wxSTC_CHARSET_SYMBOL 2 @@ -171,6 +173,7 @@ class WXDLLIMPEXP_FWD_CORE wxScrollBar; #define wxSTC_CASE_MIXED 0 #define wxSTC_CASE_UPPER 1 #define wxSTC_CASE_LOWER 2 +#define wxSTC_CASE_CAMEL 3 #define wxSTC_FONT_SIZE_MULTIPLIER 100 #define wxSTC_WEIGHT_NORMAL 400 #define wxSTC_WEIGHT_SEMIBOLD 600 @@ -248,6 +251,10 @@ class WXDLLIMPEXP_FWD_CORE wxScrollBar; #define wxSTC_FOLDFLAG_LEVELNUMBERS 0x0040 #define wxSTC_FOLDFLAG_LINESTATE 0x0080 #define wxSTC_TIME_FOREVER 10000000 +#define wxSTC_IDLESTYLING_NONE 0 +#define wxSTC_IDLESTYLING_TOVISIBLE 1 +#define wxSTC_IDLESTYLING_AFTERVISIBLE 2 +#define wxSTC_IDLESTYLING_ALL 3 #define wxSTC_WRAP_NONE 0 #define wxSTC_WRAP_WORD 1 #define wxSTC_WRAP_CHAR 2 @@ -317,7 +324,7 @@ class WXDLLIMPEXP_FWD_CORE wxScrollBar; /// If CARET_EVEN is not set, instead of having symmetrical UZs, /// the left and bottom UZs are extended up to right and top UZs respectively. -/// This way, we favour the displaying of useful information: the begining of lines, +/// This way, we favour the displaying of useful information: the beginning of lines, /// where most code reside, and the lines after the caret, eg. the body of a function. #define wxSTC_CARET_EVEN 0x08 #define wxSTC_SEL_STREAM 0 @@ -428,6 +435,11 @@ class WXDLLIMPEXP_FWD_CORE wxScrollBar; #define wxSTC_SCMOD_ALT 4 #define wxSTC_SCMOD_SUPER 8 #define wxSTC_SCMOD_META 16 +#define wxSTC_AC_FILLUP 1 +#define wxSTC_AC_DOUBLECLICK 2 +#define wxSTC_AC_TAB 3 +#define wxSTC_AC_NEWLINE 4 +#define wxSTC_AC_COMMAND 5 /// For SciLexer.h #define wxSTC_LEX_CONTAINER 0 @@ -571,7 +583,7 @@ class WXDLLIMPEXP_FWD_CORE wxScrollBar; #define wxSTC_P_WORD2 14 #define wxSTC_P_DECORATOR 15 -/// Lexical states for SCLEX_CPP +/// Lexical states for SCLEX_CPP, SCLEX_BULLANT, SCLEX_COBOL, SCLEX_TACL, SCLEX_TAL #define wxSTC_C_DEFAULT 0 #define wxSTC_C_COMMENT 1 #define wxSTC_C_COMMENTLINE 2 @@ -870,7 +882,7 @@ class WXDLLIMPEXP_FWD_CORE wxScrollBar; #define wxSTC_RB_STDERR 40 #define wxSTC_RB_UPPER_BOUND 41 -/// Lexical states for SCLEX_VB, SCLEX_VBSCRIPT, SCLEX_POWERBASIC +/// Lexical states for SCLEX_VB, SCLEX_VBSCRIPT, SCLEX_POWERBASIC, SCLEX_BLITZBASIC, SCLEX_PUREBASIC, SCLEX_FREEBASIC #define wxSTC_B_DEFAULT 0 #define wxSTC_B_COMMENT 1 #define wxSTC_B_NUMBER 2 @@ -965,6 +977,24 @@ class WXDLLIMPEXP_FWD_CORE wxScrollBar; #define wxSTC_ERR_JAVA_STACK 20 #define wxSTC_ERR_VALUE 21 #define wxSTC_ERR_GCC_INCLUDED_FROM 22 +#define wxSTC_ERR_ESCSEQ 23 +#define wxSTC_ERR_ESCSEQ_UNKNOWN 24 +#define wxSTC_ERR_ES_BLACK 40 +#define wxSTC_ERR_ES_RED 41 +#define wxSTC_ERR_ES_GREEN 42 +#define wxSTC_ERR_ES_BROWN 43 +#define wxSTC_ERR_ES_BLUE 44 +#define wxSTC_ERR_ES_MAGENTA 45 +#define wxSTC_ERR_ES_CYAN 46 +#define wxSTC_ERR_ES_GRAY 47 +#define wxSTC_ERR_ES_DARK_GRAY 48 +#define wxSTC_ERR_ES_BRIGHT_RED 49 +#define wxSTC_ERR_ES_BRIGHT_GREEN 50 +#define wxSTC_ERR_ES_YELLOW 51 +#define wxSTC_ERR_ES_BRIGHT_BLUE 52 +#define wxSTC_ERR_ES_BRIGHT_MAGENTA 53 +#define wxSTC_ERR_ES_BRIGHT_CYAN 54 +#define wxSTC_ERR_ES_WHITE 55 /// Lexical states for SCLEX_BATCH #define wxSTC_BAT_DEFAULT 0 @@ -2175,6 +2205,7 @@ class WXDLLIMPEXP_FWD_CORE wxScrollBar; #define wxSTC_COFFEESCRIPT_COMMENTBLOCK 22 #define wxSTC_COFFEESCRIPT_VERBOSE_REGEX 23 #define wxSTC_COFFEESCRIPT_VERBOSE_REGEX_COMMENT 24 +#define wxSTC_COFFEESCRIPT_INSTANCEPROPERTY 25 /// Lexical states for SCLEX_AVS #define wxSTC_AVS_DEFAULT 0 @@ -2900,7 +2931,7 @@ public: // Set the code page used to interpret the bytes of the document as characters. void SetCodePage(int codePage); - // Is the IME displayed in a winow or inline? + // Is the IME displayed in a window or inline? int GetIMEInteraction() const; // Choose to display the the IME in a winow or inline. @@ -3526,6 +3557,12 @@ public: // Retrieve the text in the target. wxString GetTargetText() const; + // Make the target range start and end be the same as the selection range start and end. + void TargetFromSelection(); + + // Sets the target to the whole document. + void TargetWholeDocument(); + // Replace the target text with the argument text. // Text is counted so it can contain NULs. // Returns the length of the replacement text. @@ -3679,6 +3716,15 @@ public: // Get position of end of word. int WordEndPosition(int pos, bool onlyWordCharacters); + // Is the range start..end considered a word? + bool IsRangeWord(int start, int end); + + // Sets limits to idle styling. + void SetIdleStyling(int idleStyling); + + // Retrieve the limits to idle styling. + int GetIdleStyling() const; + // Sets whether text is word wrapped. void SetWrapMode(int mode); @@ -3782,9 +3828,6 @@ public: // Result is NUL-terminated. wxString GetTag(int tagNumber) const; - // Make the target range start and end be the same as the selection range start and end. - void TargetFromSelection(); - // Join the lines in the target. void LinesJoin(); @@ -4285,7 +4328,7 @@ public: // Change the effect of autocompleting when there are multiple selections. void AutoCompSetMulti(int multi); - // Retrieve the effect of autocompleting when there are multiple selections.. + // Retrieve the effect of autocompleting when there are multiple selections. int AutoCompGetMulti() const; // Set the way autocompletion lists are ordered. @@ -4611,6 +4654,14 @@ public: // Swap that caret and anchor of the main selection. void SwapMainAnchorCaret(); + // Add the next occurrence of the main selection to the set of selections as main. + // If the current selection is empty then select word around caret. + void MultipleSelectAddNext(); + + // Add each occurrence of the main selection in the target to the set of selections. + // If the current selection is empty then select word around caret. + void MultipleSelectAddEach(); + // Indicate that the internal state of a lexer has changed over a range and therefore // there may be a need to redraw. int ChangeLexerState(int start, int end); diff --git a/interface/wx/stc/stc.h b/interface/wx/stc/stc.h index 62ed006e2a..f3bad2c642 100644 --- a/interface/wx/stc/stc.h +++ b/interface/wx/stc/stc.h @@ -24,6 +24,7 @@ #define wxSTC_WS_INVISIBLE 0 #define wxSTC_WS_VISIBLEALWAYS 1 #define wxSTC_WS_VISIBLEAFTERINDENT 2 +#define wxSTC_WS_VISIBLEONLYININDENT 3 #define wxSTC_EOL_CRLF 0 #define wxSTC_EOL_CR 1 #define wxSTC_EOL_LF 2 @@ -114,6 +115,7 @@ #define wxSTC_CHARSET_MAC 77 #define wxSTC_CHARSET_OEM 255 #define wxSTC_CHARSET_RUSSIAN 204 +#define wxSTC_CHARSET_OEM866 866 #define wxSTC_CHARSET_CYRILLIC 1251 #define wxSTC_CHARSET_SHIFTJIS 128 #define wxSTC_CHARSET_SYMBOL 2 @@ -127,6 +129,7 @@ #define wxSTC_CASE_MIXED 0 #define wxSTC_CASE_UPPER 1 #define wxSTC_CASE_LOWER 2 +#define wxSTC_CASE_CAMEL 3 #define wxSTC_FONT_SIZE_MULTIPLIER 100 #define wxSTC_WEIGHT_NORMAL 400 #define wxSTC_WEIGHT_SEMIBOLD 600 @@ -204,6 +207,10 @@ #define wxSTC_FOLDFLAG_LEVELNUMBERS 0x0040 #define wxSTC_FOLDFLAG_LINESTATE 0x0080 #define wxSTC_TIME_FOREVER 10000000 +#define wxSTC_IDLESTYLING_NONE 0 +#define wxSTC_IDLESTYLING_TOVISIBLE 1 +#define wxSTC_IDLESTYLING_AFTERVISIBLE 2 +#define wxSTC_IDLESTYLING_ALL 3 #define wxSTC_WRAP_NONE 0 #define wxSTC_WRAP_WORD 1 #define wxSTC_WRAP_CHAR 2 @@ -273,7 +280,7 @@ /// If CARET_EVEN is not set, instead of having symmetrical UZs, /// the left and bottom UZs are extended up to right and top UZs respectively. -/// This way, we favour the displaying of useful information: the begining of lines, +/// This way, we favour the displaying of useful information: the beginning of lines, /// where most code reside, and the lines after the caret, eg. the body of a function. #define wxSTC_CARET_EVEN 0x08 #define wxSTC_SEL_STREAM 0 @@ -384,6 +391,11 @@ #define wxSTC_SCMOD_ALT 4 #define wxSTC_SCMOD_SUPER 8 #define wxSTC_SCMOD_META 16 +#define wxSTC_AC_FILLUP 1 +#define wxSTC_AC_DOUBLECLICK 2 +#define wxSTC_AC_TAB 3 +#define wxSTC_AC_NEWLINE 4 +#define wxSTC_AC_COMMAND 5 /// For SciLexer.h #define wxSTC_LEX_CONTAINER 0 @@ -527,7 +539,7 @@ #define wxSTC_P_WORD2 14 #define wxSTC_P_DECORATOR 15 -/// Lexical states for SCLEX_CPP +/// Lexical states for SCLEX_CPP, SCLEX_BULLANT, SCLEX_COBOL, SCLEX_TACL, SCLEX_TAL #define wxSTC_C_DEFAULT 0 #define wxSTC_C_COMMENT 1 #define wxSTC_C_COMMENTLINE 2 @@ -826,7 +838,7 @@ #define wxSTC_RB_STDERR 40 #define wxSTC_RB_UPPER_BOUND 41 -/// Lexical states for SCLEX_VB, SCLEX_VBSCRIPT, SCLEX_POWERBASIC +/// Lexical states for SCLEX_VB, SCLEX_VBSCRIPT, SCLEX_POWERBASIC, SCLEX_BLITZBASIC, SCLEX_PUREBASIC, SCLEX_FREEBASIC #define wxSTC_B_DEFAULT 0 #define wxSTC_B_COMMENT 1 #define wxSTC_B_NUMBER 2 @@ -921,6 +933,24 @@ #define wxSTC_ERR_JAVA_STACK 20 #define wxSTC_ERR_VALUE 21 #define wxSTC_ERR_GCC_INCLUDED_FROM 22 +#define wxSTC_ERR_ESCSEQ 23 +#define wxSTC_ERR_ESCSEQ_UNKNOWN 24 +#define wxSTC_ERR_ES_BLACK 40 +#define wxSTC_ERR_ES_RED 41 +#define wxSTC_ERR_ES_GREEN 42 +#define wxSTC_ERR_ES_BROWN 43 +#define wxSTC_ERR_ES_BLUE 44 +#define wxSTC_ERR_ES_MAGENTA 45 +#define wxSTC_ERR_ES_CYAN 46 +#define wxSTC_ERR_ES_GRAY 47 +#define wxSTC_ERR_ES_DARK_GRAY 48 +#define wxSTC_ERR_ES_BRIGHT_RED 49 +#define wxSTC_ERR_ES_BRIGHT_GREEN 50 +#define wxSTC_ERR_ES_YELLOW 51 +#define wxSTC_ERR_ES_BRIGHT_BLUE 52 +#define wxSTC_ERR_ES_BRIGHT_MAGENTA 53 +#define wxSTC_ERR_ES_BRIGHT_CYAN 54 +#define wxSTC_ERR_ES_WHITE 55 /// Lexical states for SCLEX_BATCH #define wxSTC_BAT_DEFAULT 0 @@ -2131,6 +2161,7 @@ #define wxSTC_COFFEESCRIPT_COMMENTBLOCK 22 #define wxSTC_COFFEESCRIPT_VERBOSE_REGEX 23 #define wxSTC_COFFEESCRIPT_VERBOSE_REGEX_COMMENT 24 +#define wxSTC_COFFEESCRIPT_INSTANCEPROPERTY 25 /// Lexical states for SCLEX_AVS #define wxSTC_AVS_DEFAULT 0 @@ -3019,7 +3050,7 @@ public: void SetCodePage(int codePage); /** - Is the IME displayed in a winow or inline? + Is the IME displayed in a window or inline? */ int GetIMEInteraction() const; @@ -4040,6 +4071,16 @@ public: */ wxString GetTargetText() const; + /** + Make the target range start and end be the same as the selection range start and end. + */ + void TargetFromSelection(); + + /** + Sets the target to the whole document. + */ + void TargetWholeDocument(); + /** Replace the target text with the argument text. Text is counted so it can contain NULs. @@ -4287,6 +4328,21 @@ public: */ int WordEndPosition(int pos, bool onlyWordCharacters); + /** + Is the range start..end considered a word? + */ + bool IsRangeWord(int start, int end); + + /** + Sets limits to idle styling. + */ + void SetIdleStyling(int idleStyling); + + /** + Retrieve the limits to idle styling. + */ + int GetIdleStyling() const; + /** Sets whether text is word wrapped. */ @@ -4452,11 +4508,6 @@ public: */ wxString GetTag(int tagNumber) const; - /** - Make the target range start and end be the same as the selection range start and end. - */ - void TargetFromSelection(); - /** Join the lines in the target. */ @@ -5264,7 +5315,7 @@ public: void AutoCompSetMulti(int multi); /** - Retrieve the effect of autocompleting when there are multiple selections.. + Retrieve the effect of autocompleting when there are multiple selections. */ int AutoCompGetMulti() const; @@ -5787,6 +5838,18 @@ public: */ void SwapMainAnchorCaret(); + /** + Add the next occurrence of the main selection to the set of selections as main. + If the current selection is empty then select word around caret. + */ + void MultipleSelectAddNext(); + + /** + Add each occurrence of the main selection in the target to the set of selections. + If the current selection is empty then select word around caret. + */ + void MultipleSelectAddEach(); + /** Indicate that the internal state of a lexer has changed over a range and therefore there may be a need to redraw. diff --git a/src/stc/ScintillaWX.cpp b/src/stc/ScintillaWX.cpp index d6df4f2acb..52c7aa7882 100644 --- a/src/stc/ScintillaWX.cpp +++ b/src/stc/ScintillaWX.cpp @@ -1135,7 +1135,7 @@ void ScintillaWX::DoContextMenu(Point pt) { } void ScintillaWX::DoOnListBox() { - AutoCompleteCompleted(); + AutoCompleteCompleted(0, SC_AC_COMMAND); } diff --git a/src/stc/scintilla/README.txt b/src/stc/scintilla/README.txt index 9bedc7a813..dad146b18a 100644 --- a/src/stc/scintilla/README.txt +++ b/src/stc/scintilla/README.txt @@ -3,14 +3,14 @@ directories from the Scintilla source distribution. All other code needed to implement Scintilla on top of wxWidgets is located in the directory above this one. -The current version of the Scintilla code is 3.5.5 +The current version of the Scintilla code is 3.6.3 These are the basic steps needed to update the version of Scintilla used by wxSTC. 1. Copy include, lexers, lexlib and src folders to src/stc/scintilla 2. Examine diffs between the new src/stc/scintilla/include/Scintilla.iface -file and the version in SVN. You should get familiar especially with +file and the previous version. You should get familiar especially with new method names or constants because some of them may need to be tweaked to conform to similar naming patterns already used. (See step #6 below.) diff --git a/src/stc/scintilla/include/ILexer.h b/src/stc/scintilla/include/ILexer.h index b900927507..f01029178d 100644 --- a/src/stc/scintilla/include/ILexer.h +++ b/src/stc/scintilla/include/ILexer.h @@ -8,6 +8,8 @@ #ifndef ILEXER_H #define ILEXER_H +#include "Sci_Position.h" + #ifdef SCI_NAMESPACE namespace Scintilla { #endif @@ -24,32 +26,32 @@ class IDocument { public: virtual int SCI_METHOD Version() const = 0; virtual void SCI_METHOD SetErrorStatus(int status) = 0; - virtual int SCI_METHOD Length() const = 0; - virtual void SCI_METHOD GetCharRange(char *buffer, int position, int lengthRetrieve) const = 0; - virtual char SCI_METHOD StyleAt(int position) const = 0; - virtual int SCI_METHOD LineFromPosition(int position) const = 0; - virtual int SCI_METHOD LineStart(int line) const = 0; - virtual int SCI_METHOD GetLevel(int line) const = 0; - virtual int SCI_METHOD SetLevel(int line, int level) = 0; - virtual int SCI_METHOD GetLineState(int line) const = 0; - virtual int SCI_METHOD SetLineState(int line, int state) = 0; - virtual void SCI_METHOD StartStyling(int position, char mask) = 0; - virtual bool SCI_METHOD SetStyleFor(int length, char style) = 0; - virtual bool SCI_METHOD SetStyles(int length, const char *styles) = 0; + virtual Sci_Position SCI_METHOD Length() const = 0; + virtual void SCI_METHOD GetCharRange(char *buffer, Sci_Position position, Sci_Position lengthRetrieve) const = 0; + virtual char SCI_METHOD StyleAt(Sci_Position position) const = 0; + virtual Sci_Position SCI_METHOD LineFromPosition(Sci_Position position) const = 0; + virtual Sci_Position SCI_METHOD LineStart(Sci_Position line) const = 0; + virtual int SCI_METHOD GetLevel(Sci_Position line) const = 0; + virtual int SCI_METHOD SetLevel(Sci_Position line, int level) = 0; + virtual int SCI_METHOD GetLineState(Sci_Position line) const = 0; + virtual int SCI_METHOD SetLineState(Sci_Position line, int state) = 0; + virtual void SCI_METHOD StartStyling(Sci_Position position, char mask) = 0; + virtual bool SCI_METHOD SetStyleFor(Sci_Position length, char style) = 0; + virtual bool SCI_METHOD SetStyles(Sci_Position length, const char *styles) = 0; virtual void SCI_METHOD DecorationSetCurrentIndicator(int indicator) = 0; - virtual void SCI_METHOD DecorationFillRange(int position, int value, int fillLength) = 0; - virtual void SCI_METHOD ChangeLexerState(int start, int end) = 0; + virtual void SCI_METHOD DecorationFillRange(Sci_Position position, int value, Sci_Position fillLength) = 0; + virtual void SCI_METHOD ChangeLexerState(Sci_Position start, Sci_Position end) = 0; virtual int SCI_METHOD CodePage() const = 0; virtual bool SCI_METHOD IsDBCSLeadByte(char ch) const = 0; virtual const char * SCI_METHOD BufferPointer() = 0; - virtual int SCI_METHOD GetLineIndentation(int line) = 0; + virtual int SCI_METHOD GetLineIndentation(Sci_Position line) = 0; }; class IDocumentWithLineEnd : public IDocument { public: - virtual int SCI_METHOD LineEnd(int line) const = 0; - virtual int SCI_METHOD GetRelativePosition(int positionStart, int characterOffset) const = 0; - virtual int SCI_METHOD GetCharacterAndWidth(int position, int *pWidth) const = 0; + virtual Sci_Position SCI_METHOD LineEnd(Sci_Position line) const = 0; + virtual Sci_Position SCI_METHOD GetRelativePosition(Sci_Position positionStart, Sci_Position characterOffset) const = 0; + virtual int SCI_METHOD GetCharacterAndWidth(Sci_Position position, Sci_Position *pWidth) const = 0; }; enum { lvOriginal=0, lvSubStyles=1 }; @@ -61,11 +63,11 @@ public: virtual const char * SCI_METHOD PropertyNames() = 0; virtual int SCI_METHOD PropertyType(const char *name) = 0; virtual const char * SCI_METHOD DescribeProperty(const char *name) = 0; - virtual int SCI_METHOD PropertySet(const char *key, const char *val) = 0; + virtual Sci_Position SCI_METHOD PropertySet(const char *key, const char *val) = 0; virtual const char * SCI_METHOD DescribeWordListSets() = 0; - virtual int SCI_METHOD WordListSet(int n, const char *wl) = 0; - virtual void SCI_METHOD Lex(unsigned int startPos, int lengthDoc, int initStyle, IDocument *pAccess) = 0; - virtual void SCI_METHOD Fold(unsigned int startPos, int lengthDoc, int initStyle, IDocument *pAccess) = 0; + virtual Sci_Position SCI_METHOD WordListSet(int n, const char *wl) = 0; + virtual void SCI_METHOD Lex(Sci_PositionU startPos, Sci_Position lengthDoc, int initStyle, IDocument *pAccess) = 0; + virtual void SCI_METHOD Fold(Sci_PositionU startPos, Sci_Position lengthDoc, int initStyle, IDocument *pAccess) = 0; virtual void * SCI_METHOD PrivateCall(int operation, void *pointer) = 0; }; @@ -87,7 +89,7 @@ class ILoader { public: virtual int SCI_METHOD Release() = 0; // Returns a status code from SC_STATUS_* - virtual int SCI_METHOD AddData(char *data, int length) = 0; + virtual int SCI_METHOD AddData(char *data, Sci_Position length) = 0; virtual void * SCI_METHOD ConvertToDocument() = 0; }; diff --git a/src/stc/scintilla/include/Platform.h b/src/stc/scintilla/include/Platform.h index 4ef7e2aab2..63269d0036 100644 --- a/src/stc/scintilla/include/Platform.h +++ b/src/stc/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/src/stc/scintilla/include/SciLexer.h b/src/stc/scintilla/include/SciLexer.h index 034060a4bb..2103b47b9c 100644 --- a/src/stc/scintilla/include/SciLexer.h +++ b/src/stc/scintilla/include/SciLexer.h @@ -498,6 +498,24 @@ #define SCE_ERR_JAVA_STACK 20 #define SCE_ERR_VALUE 21 #define SCE_ERR_GCC_INCLUDED_FROM 22 +#define SCE_ERR_ESCSEQ 23 +#define SCE_ERR_ESCSEQ_UNKNOWN 24 +#define SCE_ERR_ES_BLACK 40 +#define SCE_ERR_ES_RED 41 +#define SCE_ERR_ES_GREEN 42 +#define SCE_ERR_ES_BROWN 43 +#define SCE_ERR_ES_BLUE 44 +#define SCE_ERR_ES_MAGENTA 45 +#define SCE_ERR_ES_CYAN 46 +#define SCE_ERR_ES_GRAY 47 +#define SCE_ERR_ES_DARK_GRAY 48 +#define SCE_ERR_ES_BRIGHT_RED 49 +#define SCE_ERR_ES_BRIGHT_GREEN 50 +#define SCE_ERR_ES_YELLOW 51 +#define SCE_ERR_ES_BRIGHT_BLUE 52 +#define SCE_ERR_ES_BRIGHT_MAGENTA 53 +#define SCE_ERR_ES_BRIGHT_CYAN 54 +#define SCE_ERR_ES_WHITE 55 #define SCE_BAT_DEFAULT 0 #define SCE_BAT_COMMENT 1 #define SCE_BAT_WORD 2 @@ -1567,6 +1585,7 @@ #define SCE_COFFEESCRIPT_COMMENTBLOCK 22 #define SCE_COFFEESCRIPT_VERBOSE_REGEX 23 #define SCE_COFFEESCRIPT_VERBOSE_REGEX_COMMENT 24 +#define SCE_COFFEESCRIPT_INSTANCEPROPERTY 25 #define SCE_AVS_DEFAULT 0 #define SCE_AVS_COMMENTBLOCK 1 #define SCE_AVS_COMMENTBLOCKN 2 diff --git a/src/stc/scintilla/include/Sci_Position.h b/src/stc/scintilla/include/Sci_Position.h new file mode 100644 index 0000000000..a83e2864f6 --- /dev/null +++ b/src/stc/scintilla/include/Sci_Position.h @@ -0,0 +1,21 @@ +// Scintilla source code edit control +/** @file Sci_Position.h + ** Define the Sci_Position type used in Scintilla's external interfaces. + ** These need to be available to clients written in C so are not in a C++ namespace. + **/ +// Copyright 2015 by Neil Hodgson +// The License.txt file describes the conditions under which this software may be distributed. + +#ifndef SCI_POSITION_H +#define SCI_POSITION_H + +// Basic signed type used throughout interface +typedef int Sci_Position; + +// Unsigned variant used for ILexer::Lex and ILexer::Fold +typedef unsigned int Sci_PositionU; + +// For Sci_CharacterRange which is defined as long to be compatible with Win32 CHARRANGE +typedef long Sci_PositionCR; + +#endif diff --git a/src/stc/scintilla/include/Scintilla.h b/src/stc/scintilla/include/Scintilla.h index 22d36d34d9..c985cea778 100644 --- a/src/stc/scintilla/include/Scintilla.h +++ b/src/stc/scintilla/include/Scintilla.h @@ -11,6 +11,8 @@ #ifndef SCINTILLA_H #define SCINTILLA_H +#include "Sci_Position.h" + #ifdef __cplusplus extern "C" { #endif @@ -71,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 @@ -194,6 +197,7 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SC_CHARSET_MAC 77 #define SC_CHARSET_OEM 255 #define SC_CHARSET_RUSSIAN 204 +#define SC_CHARSET_OEM866 866 #define SC_CHARSET_CYRILLIC 1251 #define SC_CHARSET_SHIFTJIS 128 #define SC_CHARSET_SYMBOL 2 @@ -217,6 +221,7 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SC_CASE_MIXED 0 #define SC_CASE_UPPER 1 #define SC_CASE_LOWER 2 +#define SC_CASE_CAMEL 3 #define SCI_STYLEGETFORE 2481 #define SCI_STYLEGETBACK 2482 #define SCI_STYLEGETBOLD 2483 @@ -434,6 +439,8 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SCI_GETTARGETEND 2193 #define SCI_SETTARGETRANGE 2686 #define SCI_GETTARGETTEXT 2687 +#define SCI_TARGETFROMSELECTION 2287 +#define SCI_TARGETWHOLEDOCUMENT 2690 #define SCI_REPLACETARGET 2194 #define SCI_REPLACETARGETRE 2195 #define SCI_SEARCHINTARGET 2197 @@ -498,6 +505,13 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SCI_GETMOUSEDWELLTIME 2265 #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 @@ -559,7 +573,6 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SCI_SETMULTIPASTE 2614 #define SCI_GETMULTIPASTE 2615 #define SCI_GETTAG 2616 -#define SCI_TARGETFROMSELECTION 2287 #define SCI_LINESJOIN 2288 #define SCI_LINESSPLIT 2289 #define SCI_SETFOLDMARGINCOLOUR 2290 @@ -894,6 +907,8 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SCI_GETADDITIONALCARETFORE 2605 #define SCI_ROTATESELECTION 2606 #define SCI_SWAPMAINANCHORCARET 2607 +#define SCI_MULTIPLESELECTADDNEXT 2688 +#define SCI_MULTIPLESELECTADDEACH 2689 #define SCI_CHANGELEXERSTATE 2617 #define SCI_CONTRACTEDFOLDNEXT 2618 #define SCI_VERTICALCENTRECARET 2619 @@ -1019,6 +1034,11 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SCMOD_ALT 4 #define SCMOD_SUPER 8 #define SCMOD_META 16 +#define SC_AC_FILLUP 1 +#define SC_AC_DOUBLECLICK 2 +#define SC_AC_TAB 3 +#define SC_AC_NEWLINE 4 +#define SC_AC_COMMAND 5 #define SCN_STYLENEEDED 2000 #define SCN_CHARADDED 2001 #define SCN_SAVEPOINTREACHED 2002 @@ -1048,6 +1068,7 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SCN_HOTSPOTRELEASECLICK 2027 #define SCN_FOCUSIN 2028 #define SCN_FOCUSOUT 2029 +#define SCN_AUTOCCOMPLETED 2030 /* --Autogenerated -- end of section automatically generated from Scintilla.iface */ /* These structures are defined to be exactly the same shape as the Win32 @@ -1059,8 +1080,8 @@ namespace Scintilla { #endif struct Sci_CharacterRange { - long cpMin; - long cpMax; + Sci_PositionCR cpMin; + Sci_PositionCR cpMax; }; struct Sci_TextRange { @@ -1113,14 +1134,16 @@ struct Sci_NotifyHeader { struct SCNotification { struct Sci_NotifyHeader nmhdr; - int position; + Sci_Position position; /* SCN_STYLENEEDED, SCN_DOUBLECLICK, SCN_MODIFIED, SCN_MARGINCLICK, */ /* SCN_NEEDSHOWN, SCN_DWELLSTART, SCN_DWELLEND, SCN_CALLTIPCLICK, */ /* SCN_HOTSPOTCLICK, SCN_HOTSPOTDOUBLECLICK, SCN_HOTSPOTRELEASECLICK, */ /* SCN_INDICATORCLICK, SCN_INDICATORRELEASE, */ /* SCN_USERLISTSELECTION, SCN_AUTOCSELECTION */ - int ch; /* SCN_CHARADDED, SCN_KEY */ + int ch; + /* SCN_CHARADDED, SCN_KEY, SCN_AUTOCCOMPLETED, SCN_AUTOCSELECTION, */ + /* SCN_USERLISTSELECTION */ int modifiers; /* SCN_KEY, SCN_DOUBLECLICK, SCN_HOTSPOTCLICK, SCN_HOTSPOTDOUBLECLICK, */ /* SCN_HOTSPOTRELEASECLICK, SCN_INDICATORCLICK, SCN_INDICATORRELEASE, */ @@ -1129,12 +1152,12 @@ struct SCNotification { const char *text; /* SCN_MODIFIED, SCN_USERLISTSELECTION, SCN_AUTOCSELECTION, SCN_URIDROPPED */ - int length; /* SCN_MODIFIED */ - int linesAdded; /* SCN_MODIFIED */ + Sci_Position length; /* SCN_MODIFIED */ + Sci_Position linesAdded; /* SCN_MODIFIED */ int message; /* SCN_MACRORECORD */ uptr_t wParam; /* SCN_MACRORECORD */ sptr_t lParam; /* SCN_MACRORECORD */ - int line; /* SCN_MODIFIED */ + Sci_Position line; /* SCN_MODIFIED */ int foldLevelNow; /* SCN_MODIFIED */ int foldLevelPrev; /* SCN_MODIFIED */ int margin; /* SCN_MARGINCLICK */ @@ -1142,8 +1165,10 @@ struct SCNotification { int x; /* SCN_DWELLSTART, SCN_DWELLEND */ int y; /* SCN_DWELLSTART, SCN_DWELLEND */ int token; /* SCN_MODIFIED with SC_MOD_CONTAINER */ - int annotationLinesAdded; /* SCN_MODIFIED with SC_MOD_CHANGEANNOTATION */ + Sci_Position annotationLinesAdded; /* SCN_MODIFIED with SC_MOD_CHANGEANNOTATION */ int updated; /* SCN_UPDATEUI */ + int listCompletionMethod; + /* SCN_AUTOCSELECTION, SCN_AUTOCCOMPLETED, SCN_USERLISTSELECTION, */ }; #if defined(__cplusplus) && defined(SCI_NAMESPACE) diff --git a/src/stc/scintilla/include/Scintilla.iface b/src/stc/scintilla/include/Scintilla.iface index 6432d37aa8..91b3066b52 100644 --- a/src/stc/scintilla/include/Scintilla.iface +++ b/src/stc/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 @@ -417,6 +418,7 @@ val SC_CHARSET_HANGUL=129 val SC_CHARSET_MAC=77 val SC_CHARSET_OEM=255 val SC_CHARSET_RUSSIAN=204 +val SC_CHARSET_OEM866=866 val SC_CHARSET_CYRILLIC=1251 val SC_CHARSET_SHIFTJIS=128 val SC_CHARSET_SYMBOL=2 @@ -462,6 +464,7 @@ enu CaseVisible=SC_CASE_ val SC_CASE_MIXED=0 val SC_CASE_UPPER=1 val SC_CASE_LOWER=2 +val SC_CASE_CAMEL=3 # Get the foreground colour of a style. get colour StyleGetFore=2481(int style,) @@ -1069,6 +1072,12 @@ fun void SetTargetRange=2686(position start, position end) # Retrieve the text in the target. get int GetTargetText=2687(, stringresult characters) +# Make the target range start and end be the same as the selection range start and end. +fun void TargetFromSelection=2287(,) + +# Sets the target to the whole document. +fun void TargetWholeDocument=2690(,) + # Replace the target text with the argument text. # Text is counted so it can contain NULs. # Returns the length of the replacement text. @@ -1248,6 +1257,21 @@ fun int WordStartPosition=2266(position pos, bool onlyWordCharacters) # Get position of end of word. 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 @@ -1396,16 +1420,13 @@ 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. # Result is NUL-terminated. get int GetTag=2616(int tagNumber, stringresult tagValue) -# Make the target range start and end be the same as the selection range start and end. -fun void TargetFromSelection=2287(,) - # Join the lines in the target. fun void LinesJoin=2288(,) @@ -1785,7 +1806,7 @@ val CARET_STRICT=0x04 val CARET_JUMPS=0x10 # If CARET_EVEN is not set, instead of having symmetrical UZs, # the left and bottom UZs are extended up to right and top UZs respectively. -# This way, we favour the displaying of useful information: the begining of lines, +# This way, we favour the displaying of useful information: the beginning of lines, # where most code reside, and the lines after the caret, eg. the body of a function. val CARET_EVEN=0x08 @@ -1968,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_ @@ -2350,6 +2371,14 @@ fun void RotateSelection=2606(,) # Swap that caret and anchor of the main selection. fun void SwapMainAnchorCaret=2607(,) +# Add the next occurrence of the main selection to the set of selections as main. +# If the current selection is empty then select word around caret. +fun void MultipleSelectAddNext=2688(,) + +# Add each occurrence of the main selection in the target to the set of selections. +# If the current selection is empty then select word around caret. +fun void MultipleSelectAddEach=2689(,) + # Indicate that the internal state of a lexer has changed over a range and therefore # there may be a need to redraw. fun int ChangeLexerState=2617(position start, position end) @@ -2642,6 +2671,13 @@ val SCMOD_ALT=4 val SCMOD_SUPER=8 val SCMOD_META=16 +enu CompletionMethods=SC_AC_ +val SC_AC_FILLUP=1 +val SC_AC_DOUBLECLICK=2 +val SC_AC_TAB=3 +val SC_AC_NEWLINE=4 +val SC_AC_COMMAND=5 + ################################################ # For SciLexer.h enu Lexer=SCLEX_ @@ -2786,9 +2822,12 @@ val SCE_P_COMMENTBLOCK=12 val SCE_P_STRINGEOL=13 val SCE_P_WORD2=14 val SCE_P_DECORATOR=15 -# Lexical states for SCLEX_CPP +# Lexical states for SCLEX_CPP, SCLEX_BULLANT, SCLEX_COBOL, SCLEX_TACL, SCLEX_TAL lex Cpp=SCLEX_CPP SCE_C_ lex BullAnt=SCLEX_BULLANT SCE_C_ +lex COBOL=SCLEX_COBOL SCE_C_ +lex TACL=SCLEX_TACL SCE_C_ +lex TAL=SCLEX_TAL SCE_C_ val SCE_C_DEFAULT=0 val SCE_C_COMMENT=1 val SCE_C_COMMENTLINE=2 @@ -3075,10 +3114,13 @@ val SCE_RB_STDIN=30 val SCE_RB_STDOUT=31 val SCE_RB_STDERR=40 val SCE_RB_UPPER_BOUND=41 -# Lexical states for SCLEX_VB, SCLEX_VBSCRIPT, SCLEX_POWERBASIC +# Lexical states for SCLEX_VB, SCLEX_VBSCRIPT, SCLEX_POWERBASIC, SCLEX_BLITZBASIC, SCLEX_PUREBASIC, SCLEX_FREEBASIC lex VB=SCLEX_VB SCE_B_ lex VBScript=SCLEX_VBSCRIPT SCE_B_ lex PowerBasic=SCLEX_POWERBASIC SCE_B_ +lex BlitzBasic=SCLEX_BLITZBASIC SCE_B_ +lex PureBasic=SCLEX_PUREBASIC SCE_B_ +lex FreeBasic=SCLEX_FREEBASIC SCE_B_ val SCE_B_DEFAULT=0 val SCE_B_COMMENT=1 val SCE_B_NUMBER=2 @@ -3173,6 +3215,24 @@ val SCE_ERR_TIDY=19 val SCE_ERR_JAVA_STACK=20 val SCE_ERR_VALUE=21 val SCE_ERR_GCC_INCLUDED_FROM=22 +val SCE_ERR_ESCSEQ=23 +val SCE_ERR_ESCSEQ_UNKNOWN=24 +val SCE_ERR_ES_BLACK=40 +val SCE_ERR_ES_RED=41 +val SCE_ERR_ES_GREEN=42 +val SCE_ERR_ES_BROWN=43 +val SCE_ERR_ES_BLUE=44 +val SCE_ERR_ES_MAGENTA=45 +val SCE_ERR_ES_CYAN=46 +val SCE_ERR_ES_GRAY=47 +val SCE_ERR_ES_DARK_GRAY=48 +val SCE_ERR_ES_BRIGHT_RED=49 +val SCE_ERR_ES_BRIGHT_GREEN=50 +val SCE_ERR_ES_YELLOW=51 +val SCE_ERR_ES_BRIGHT_BLUE=52 +val SCE_ERR_ES_BRIGHT_MAGENTA=53 +val SCE_ERR_ES_BRIGHT_CYAN=54 +val SCE_ERR_ES_WHITE=55 # Lexical states for SCLEX_BATCH lex Batch=SCLEX_BATCH SCE_BAT_ val SCE_BAT_DEFAULT=0 @@ -4387,6 +4447,7 @@ val SCE_COFFEESCRIPT_TRIPLEVERBATIM=21 val SCE_COFFEESCRIPT_COMMENTBLOCK=22 val SCE_COFFEESCRIPT_VERBOSE_REGEX=23 val SCE_COFFEESCRIPT_VERBOSE_REGEX_COMMENT=24 +val SCE_COFFEESCRIPT_INSTANCEPROPERTY=25 # Lexical states for SCLEX_AVS lex AVS=SCLEX_AVS SCE_AVS_ val SCE_AVS_DEFAULT=0 @@ -4633,7 +4694,7 @@ evt void MacroRecord=2009(int message, int wParam, int lParam) evt void MarginClick=2010(int modifiers, int position, int margin) evt void NeedShown=2011(int position, int length) evt void Painted=2013(void) -evt void UserListSelection=2014(int listType, string text, int position) +evt void UserListSelection=2014(int listType, string text, int positionint, int ch, CompletionMethods listCompletionMethod) evt void URIDropped=2015(string text) evt void DwellStart=2016(int position, int x, int y) evt void DwellEnd=2017(int position, int x, int y) @@ -4641,7 +4702,7 @@ evt void Zoom=2018(void) evt void HotSpotClick=2019(int modifiers, int position) evt void HotSpotDoubleClick=2020(int modifiers, int position) evt void CallTipClick=2021(int position) -evt void AutoCSelection=2022(string text, int position) +evt void AutoCSelection=2022(string text, int position, int ch, CompletionMethods listCompletionMethod) evt void IndicatorClick=2023(int modifiers, int position) evt void IndicatorRelease=2024(int modifiers, int position) evt void AutoCCancelled=2025(void) @@ -4649,6 +4710,7 @@ evt void AutoCCharDeleted=2026(void) evt void HotSpotReleaseClick=2027(int modifiers, int position) evt void FocusIn=2028(void) evt void FocusOut=2029(void) +evt void AutoCCompleted=2030(string text, int position, int ch, CompletionMethods listCompletionMethod) # There are no provisional features currently diff --git a/src/stc/scintilla/include/ScintillaWidget.h b/src/stc/scintilla/include/ScintillaWidget.h index f8cd212b02..2c3d12dbe6 100644 --- a/src/stc/scintilla/include/ScintillaWidget.h +++ b/src/stc/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/src/stc/scintilla/lexers/LexA68k.cxx b/src/stc/scintilla/lexers/LexA68k.cxx index 0b600195a7..b5f48987ec 100644 --- a/src/stc/scintilla/lexers/LexA68k.cxx +++ b/src/stc/scintilla/lexers/LexA68k.cxx @@ -115,22 +115,22 @@ static inline bool IsDoxygenChar (const int ch) * Main function, which colourises a 68k source */ -static void ColouriseA68kDoc (unsigned int startPos, int length, int initStyle, WordList *keywordlists[], Accessor &styler) +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 (unsigned int startPos, int length, int initStyle, /************************************************************ * - * 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 (unsigned int startPos, int length, int initStyle, * ************************************************************/ - // 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. - if (sc.atLineStart && (sc.ch < 0x80) && IsIdentifierStart(sc.ch)) { - sc.SetState(SCE_A68K_MACRO_DECLARATION); + // 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); } - 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 + + 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. + if (sc.atLineStart && (sc.ch < 0x80) && IsIdentifierStart(sc.ch)) { + 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) && isdigit(sc.ch)) { // Decimal numbers haven't prefix sc.SetState(SCE_A68K_NUMBER_DEC); @@ -309,7 +309,7 @@ static void ColouriseA68kDoc (unsigned int startPos, int length, int initStyle, 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/src/stc/scintilla/lexers/LexAPDL.cxx b/src/stc/scintilla/lexers/LexAPDL.cxx index 7d65a56153..873ec9d13b 100644 --- a/src/stc/scintilla/lexers/LexAPDL.cxx +++ b/src/stc/scintilla/lexers/LexAPDL.cxx @@ -43,7 +43,7 @@ static inline bool IsAnOperator(char ch) { return false; } -static void ColouriseAPDLDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[], +static void ColouriseAPDLDoc(Sci_PositionU startPos, Sci_Position length, int initStyle, WordList *keywordlists[], Accessor &styler) { int stringStart = ' '; @@ -184,16 +184,16 @@ static int CheckAPDLFoldPoint(char const *token, int &level) { return 0; } -static void FoldAPDLDoc(unsigned int startPos, int length, int, +static void FoldAPDLDoc(Sci_PositionU startPos, Sci_Position length, int, WordList *[], Accessor &styler) { - int line = styler.GetLine(startPos); + Sci_Position line = styler.GetLine(startPos); int level = styler.LevelAt(line); int go = 0, done = 0; - int endPos = startPos + length; + Sci_Position endPos = startPos + length; char word[256]; int wordlen = 0; - int i; + Sci_Position i; bool foldCompact = styler.GetPropertyInt("fold.compact", 1) != 0; // Scan for tokens at the start of the line (they may include // whitespace, for tokens like "End Function" diff --git a/src/stc/scintilla/lexers/LexASY.cxx b/src/stc/scintilla/lexers/LexASY.cxx index 9e3470cda3..b49975e706 100644 --- a/src/stc/scintilla/lexers/LexASY.cxx +++ b/src/stc/scintilla/lexers/LexASY.cxx @@ -23,7 +23,7 @@ using namespace Scintilla; #endif -static void ColouriseAsyDoc(unsigned int startPos, int length, int initStyle, +static void ColouriseAsyDoc(Sci_PositionU startPos, Sci_Position length, int initStyle, WordList *keywordlists[], Accessor &styler) { WordList &keywords = *keywordlists[0]; @@ -152,7 +152,7 @@ static inline bool isASYidentifier(int ch) { ((ch >= 'a') && (ch <= 'z')) || ((ch >= 'A') && (ch <= 'Z')) ; } -static int ParseASYWord(unsigned int pos, Accessor &styler, char *word) +static int ParseASYWord(Sci_PositionU pos, Accessor &styler, char *word) { int length=0; char ch=styler.SafeGetCharAt(pos); @@ -167,11 +167,11 @@ static int ParseASYWord(unsigned int pos, Accessor &styler, char *word) return length; } -static bool IsASYDrawingLine(int line, Accessor &styler) { - int pos = styler.LineStart(line); - int eol_pos = styler.LineStart(line + 1) - 1; +static bool IsASYDrawingLine(Sci_Position line, Accessor &styler) { + Sci_Position pos = styler.LineStart(line); + Sci_Position eol_pos = styler.LineStart(line + 1) - 1; - int startpos = pos; + Sci_Position startpos = pos; char buffer[100]=""; while (startpos 0) levelCurrent = styler.LevelAt(lineCurrent-1) >> 16; @@ -202,7 +202,7 @@ static void FoldAsyDoc(unsigned int startPos, int length, int initStyle, char chNext = styler[startPos]; int styleNext = styler.StyleAt(startPos); int style = initStyle; - for (unsigned int i = startPos; i < endPos; i++) { + for (Sci_PositionU i = startPos; i < endPos; i++) { char ch = chNext; chNext = styler.SafeGetCharAt(i + 1); int stylePrev = style; diff --git a/src/stc/scintilla/lexers/LexAU3.cxx b/src/stc/scintilla/lexers/LexAU3.cxx index 68f1798d33..c8ab9d7008 100644 --- a/src/stc/scintilla/lexers/LexAU3.cxx +++ b/src/stc/scintilla/lexers/LexAU3.cxx @@ -170,10 +170,10 @@ static int GetSendKey(const char *szLine, char *szKey) // // Routine to check the last "none comment" character on a line to see if its a continuation // -static bool IsContinuationLine(unsigned int szLine, Accessor &styler) +static bool IsContinuationLine(Sci_PositionU szLine, Accessor &styler) { - int nsPos = styler.LineStart(szLine); - int nePos = styler.LineStart(szLine+1) - 2; + Sci_Position nsPos = styler.LineStart(szLine); + Sci_Position nePos = styler.LineStart(szLine+1) - 2; //int stylech = styler.StyleAt(nsPos); while (nsPos < nePos) { @@ -195,8 +195,8 @@ static bool IsContinuationLine(unsigned int szLine, Accessor &styler) // // syntax highlighting logic -static void ColouriseAU3Doc(unsigned int startPos, - int length, int initStyle, +static void ColouriseAU3Doc(Sci_PositionU startPos, + Sci_Position length, int initStyle, WordList *keywordlists[], Accessor &styler) { @@ -209,8 +209,8 @@ static void ColouriseAU3Doc(unsigned int startPos, WordList &keywords7 = *keywordlists[6]; WordList &keywords8 = *keywordlists[7]; // find the first previous line without continuation character at the end - int lineCurrent = styler.GetLine(startPos); - int s_startPos = startPos; + Sci_Position lineCurrent = styler.GetLine(startPos); + Sci_Position s_startPos = startPos; // When not inside a Block comment: find First line without _ if (!(initStyle==SCE_AU3_COMMENTBLOCK)) { while ((lineCurrent > 0 && IsContinuationLine(lineCurrent,styler)) || @@ -447,7 +447,7 @@ static void ColouriseAU3Doc(unsigned int startPos, { si=0; // at line end and not found a continuation char then reset to default - int lineCurrent = styler.GetLine(sc.currentPos); + Sci_Position lineCurrent = styler.GetLine(sc.currentPos); if (!IsContinuationLine(lineCurrent,styler)) { sc.SetState(SCE_AU3_DEFAULT); @@ -492,7 +492,7 @@ static void ColouriseAU3Doc(unsigned int startPos, else { // check if the start is a valid SendKey start - int nPos = 0; + Sci_Position nPos = 0; int nState = 1; char cTemp; while (!(nState == 2) && ((cTemp = s[nPos]) != '\0')) @@ -659,10 +659,10 @@ static bool IsStreamCommentStyle(int style) { // // Routine to find first none space on the current line and return its Style // needed for comment lines not starting on pos 1 -static int GetStyleFirstWord(unsigned int szLine, Accessor &styler) +static int GetStyleFirstWord(Sci_PositionU szLine, Accessor &styler) { - int nsPos = styler.LineStart(szLine); - int nePos = styler.LineStart(szLine+1) - 1; + Sci_Position nsPos = styler.LineStart(szLine); + Sci_Position nePos = styler.LineStart(szLine+1) - 1; while (isspacechar(styler.SafeGetCharAt(nsPos)) && nsPos < nePos) { nsPos++; // skip to next char @@ -674,16 +674,16 @@ static int GetStyleFirstWord(unsigned int szLine, Accessor &styler) // -static void FoldAU3Doc(unsigned int startPos, int length, int, WordList *[], Accessor &styler) +static void FoldAU3Doc(Sci_PositionU startPos, Sci_Position length, int, WordList *[], Accessor &styler) { - int endPos = startPos + length; + Sci_Position endPos = startPos + length; // get settings from the config files for folding comments and preprocessor lines bool foldComment = styler.GetPropertyInt("fold.comment") != 0; bool foldInComment = styler.GetPropertyInt("fold.comment") == 2; bool foldCompact = styler.GetPropertyInt("fold.compact", 1) != 0; bool foldpreprocessor = styler.GetPropertyInt("fold.preprocessor") != 0; // Backtrack to previous line in case need to fix its fold status - int lineCurrent = styler.GetLine(startPos); + Sci_Position lineCurrent = styler.GetLine(startPos); if (startPos > 0) { if (lineCurrent > 0) { lineCurrent--; @@ -720,7 +720,7 @@ static void FoldAU3Doc(unsigned int startPos, int length, int, WordList *[], Acc char chNext = styler.SafeGetCharAt(startPos); char chPrev = ' '; // - for (int i = startPos; i < endPos; i++) { + for (Sci_Position i = startPos; i < endPos; i++) { char ch = chNext; chNext = styler.SafeGetCharAt(i + 1); if (IsAWordChar(ch)) { diff --git a/src/stc/scintilla/lexers/LexAVE.cxx b/src/stc/scintilla/lexers/LexAVE.cxx index 8f5729e3d8..fd99273797 100644 --- a/src/stc/scintilla/lexers/LexAVE.cxx +++ b/src/stc/scintilla/lexers/LexAVE.cxx @@ -59,8 +59,8 @@ inline bool isAveOperator(char ch) { } static void ColouriseAveDoc( - unsigned int startPos, - int length, + Sci_PositionU startPos, + Sci_Position length, int initStyle, WordList *keywordlists[], Accessor &styler) { @@ -82,7 +82,7 @@ static void ColouriseAveDoc( for (; sc.More(); sc.Forward()) { if (sc.atLineEnd) { // Update the line state, so it can be seen by next line - int currentLine = styler.GetLine(sc.currentPos); + Sci_Position currentLine = styler.GetLine(sc.currentPos); styler.SetLineState(currentLine, 0); } if (sc.atLineStart && (sc.state == SCE_AVE_STRING)) { @@ -157,11 +157,11 @@ static void ColouriseAveDoc( sc.Complete(); } -static void FoldAveDoc(unsigned int startPos, int length, int /* initStyle */, WordList *[], +static void FoldAveDoc(Sci_PositionU startPos, Sci_Position length, int /* initStyle */, WordList *[], Accessor &styler) { - unsigned int lengthDoc = startPos + length; + Sci_PositionU lengthDoc = startPos + length; int visibleChars = 0; - int lineCurrent = styler.GetLine(startPos); + Sci_Position lineCurrent = styler.GetLine(startPos); int levelPrev = styler.LevelAt(lineCurrent) & SC_FOLDLEVELNUMBERMASK; int levelCurrent = levelPrev; char chNext = static_cast(tolower(styler[startPos])); @@ -169,7 +169,7 @@ static void FoldAveDoc(unsigned int startPos, int length, int /* initStyle */, W int styleNext = styler.StyleAt(startPos); char s[10] = ""; - for (unsigned int i = startPos; i < lengthDoc; i++) { + for (Sci_PositionU i = startPos; i < lengthDoc; i++) { char ch = static_cast(tolower(chNext)); chNext = static_cast(tolower(styler.SafeGetCharAt(i + 1))); int style = styleNext; diff --git a/src/stc/scintilla/lexers/LexAVS.cxx b/src/stc/scintilla/lexers/LexAVS.cxx index 82e4345790..129c3563b3 100644 --- a/src/stc/scintilla/lexers/LexAVS.cxx +++ b/src/stc/scintilla/lexers/LexAVS.cxx @@ -44,8 +44,8 @@ static inline bool IsANumberChar(int ch) { } static void ColouriseAvsDoc( - unsigned int startPos, - int length, + Sci_PositionU startPos, + Sci_Position length, int initStyle, WordList *keywordlists[], Accessor &styler) { @@ -57,7 +57,7 @@ static void ColouriseAvsDoc( WordList &clipProperties = *keywordlists[4]; WordList &userDefined = *keywordlists[5]; - int currentLine = styler.GetLine(startPos); + Sci_Position currentLine = styler.GetLine(startPos); // Initialize the block comment nesting level, if we are inside such a comment. int blockCommentLevel = 0; if (initStyle == SCE_AVS_COMMENTBLOCK || initStyle == SCE_AVS_COMMENTBLOCKN) { @@ -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); @@ -208,24 +208,24 @@ static void ColouriseAvsDoc( } static void FoldAvsDoc( - unsigned int startPos, - int length, + Sci_PositionU startPos, + Sci_Position length, int initStyle, WordList *[], Accessor &styler) { bool foldComment = styler.GetPropertyInt("fold.comment") != 0; bool foldCompact = styler.GetPropertyInt("fold.compact", 1) != 0; - unsigned int endPos = startPos + length; + Sci_PositionU endPos = startPos + length; int visibleChars = 0; - int lineCurrent = styler.GetLine(startPos); + Sci_Position lineCurrent = styler.GetLine(startPos); int levelPrev = styler.LevelAt(lineCurrent) & SC_FOLDLEVELNUMBERMASK; int levelCurrent = levelPrev; char chNext = styler[startPos]; int styleNext = styler.StyleAt(startPos); int style = initStyle; - for (unsigned int i = startPos; i < endPos; i++) { + for (Sci_PositionU i = startPos; i < endPos; i++) { char ch = chNext; chNext = styler.SafeGetCharAt(i + 1); int stylePrev = style; diff --git a/src/stc/scintilla/lexers/LexAbaqus.cxx b/src/stc/scintilla/lexers/LexAbaqus.cxx index d93aa503d9..509d89a0ae 100644 --- a/src/stc/scintilla/lexers/LexAbaqus.cxx +++ b/src/stc/scintilla/lexers/LexAbaqus.cxx @@ -38,7 +38,7 @@ static inline bool IsASetChar(const int ch) { return (ch < 0x80 && (isalnum(ch) || (ch == '_') || (ch == '.') || (ch == '-'))); } -static void ColouriseABAQUSDoc(unsigned int startPos, int length, int initStyle, WordList*[] /* *keywordlists[] */, +static void ColouriseABAQUSDoc(Sci_PositionU startPos, Sci_Position length, int initStyle, WordList*[] /* *keywordlists[] */, Accessor &styler) { enum localState { KW_LINE_KW, KW_LINE_COMMA, KW_LINE_PAR, KW_LINE_EQ, KW_LINE_VAL, \ DAT_LINE_VAL, DAT_LINE_COMMA,\ @@ -301,10 +301,10 @@ static int LowerCase(int c) return c; } -static int LineEnd(int line, Accessor &styler) +static Sci_Position LineEnd(Sci_Position line, Accessor &styler) { - const int docLines = styler.GetLine(styler.Length() - 1); // Available last line - int eol_pos ; + const Sci_Position docLines = styler.GetLine(styler.Length() - 1); // Available last line + Sci_Position eol_pos ; // if the line is the last line, the eol_pos is styler.Length() // eol will contain a new line, or a virtual new line if ( docLines == line ) @@ -314,7 +314,7 @@ static int LineEnd(int line, Accessor &styler) return eol_pos ; } -static int LineStart(int line, Accessor &styler) +static Sci_Position LineStart(Sci_Position line, Accessor &styler) { return styler.LineStart(line) ; } @@ -330,14 +330,14 @@ static int LineStart(int line, Accessor &styler) // 6 : block close keyword line // 7 : keyword line in error // 8 : comment line -static int LineType(int line, Accessor &styler) { - int pos = LineStart(line, styler) ; - int eol_pos = LineEnd(line, styler) ; +static int LineType(Sci_Position line, Accessor &styler) { + Sci_Position pos = LineStart(line, styler) ; + Sci_Position eol_pos = LineEnd(line, styler) ; int c ; char ch = ' '; - int i = pos ; + Sci_Position i = pos ; while ( i < eol_pos ) { c = styler.SafeGetCharAt(i); ch = static_cast(LowerCase(c)); @@ -418,7 +418,7 @@ static int LineType(int line, Accessor &styler) { return 4 ; } -static void SafeSetLevel(int line, int level, Accessor &styler) +static void SafeSetLevel(Sci_Position line, int level, Accessor &styler) { if ( line < 0 ) return ; @@ -432,20 +432,20 @@ static void SafeSetLevel(int line, int level, Accessor &styler) styler.SetLevel(line, level) ; } -static void FoldABAQUSDoc(unsigned int startPos, int length, int, +static void FoldABAQUSDoc(Sci_PositionU startPos, Sci_Position length, int, WordList *[], Accessor &styler) { - int startLine = styler.GetLine(startPos) ; - int endLine = styler.GetLine(startPos+length-1) ; + Sci_Position startLine = styler.GetLine(startPos) ; + Sci_Position endLine = styler.GetLine(startPos+length-1) ; // bool foldCompact = styler.GetPropertyInt("fold.compact", 1) != 0; // We want to deal with all the cases // To know the correct indentlevel, we need to look back to the // previous command line indentation level // order of formatting keyline datalines commentlines - int beginData = -1 ; - int beginComment = -1 ; - int prvKeyLine = startLine ; - int prvKeyLineTp = 0 ; + Sci_Position beginData = -1 ; + Sci_Position beginComment = -1 ; + Sci_Position prvKeyLine = startLine ; + Sci_Position prvKeyLineTp = 0 ; // Scan until we find the previous keyword line // this will give us the level reference that we need @@ -467,7 +467,7 @@ WordList *[], Accessor &styler) { prvKeyLine = -1 ; // Now start scanning over the lines. - for ( int line = startLine; line <= endLine; line++ ) { + for ( Sci_Position line = startLine; line <= endLine; line++ ) { int lineType = LineType(line, styler) ; // Check for comment line @@ -516,7 +516,7 @@ WordList *[], Accessor &styler) { datLevel = level ; } - for ( int ll = beginData; ll < beginComment; ll++ ) + for ( Sci_Position ll = beginData; ll < beginComment; ll++ ) SafeSetLevel(ll, datLevel, styler) ; // The keyword we just found is going to be written at another level @@ -532,7 +532,7 @@ WordList *[], Accessor &styler) { } } - for ( int lll = beginComment; lll < line; lll++ ) + for ( Sci_Position lll = beginComment; lll < line; lll++ ) SafeSetLevel(lll, level, styler) ; // wrap and reset @@ -549,10 +549,10 @@ WordList *[], Accessor &styler) { } else { // We need to find out whether this comment block is followed by // a data line or a keyword line - const int docLines = styler.GetLine(styler.Length() - 1); + const Sci_Position docLines = styler.GetLine(styler.Length() - 1); - for ( int line = endLine + 1; line <= docLines; line++ ) { - int lineType = LineType(line, styler) ; + for ( Sci_Position line = endLine + 1; line <= docLines; line++ ) { + Sci_Position lineType = LineType(line, styler) ; if ( lineType != 8 ) { if ( !(lineType & 4) ) { @@ -578,7 +578,7 @@ WordList *[], Accessor &styler) { datLevel = level ; } - for ( int ll = beginData; ll < beginComment; ll++ ) + for ( Sci_Position ll = beginData; ll < beginComment; ll++ ) SafeSetLevel(ll, datLevel, styler) ; if ( prvKeyLineTp == 5 ) { @@ -588,7 +588,7 @@ WordList *[], Accessor &styler) { if ( prvKeyLineTp == 6 ) { level -= 1 ; } - for ( int m = beginComment; m <= endLine; m++ ) + for ( Sci_Position m = beginComment; m <= endLine; m++ ) SafeSetLevel(m, level, styler) ; } diff --git a/src/stc/scintilla/lexers/LexAda.cxx b/src/stc/scintilla/lexers/LexAda.cxx index 7a7dea60f6..df26d75784 100644 --- a/src/stc/scintilla/lexers/LexAda.cxx +++ b/src/stc/scintilla/lexers/LexAda.cxx @@ -34,8 +34,8 @@ using namespace Scintilla; */ static void ColouriseDocument( - unsigned int startPos, - int length, + Sci_PositionU startPos, + Sci_Position length, int initStyle, WordList *keywordlists[], Accessor &styler); @@ -222,8 +222,8 @@ static void ColouriseWord(StyleContext& sc, WordList& keywords, bool& apostrophe // static void ColouriseDocument( - unsigned int startPos, - int length, + Sci_PositionU startPos, + Sci_Position length, int initStyle, WordList *keywordlists[], Accessor &styler) { @@ -231,7 +231,7 @@ static void ColouriseDocument( StyleContext sc(startPos, length, initStyle, styler); - int lineCurrent = styler.GetLine(startPos); + Sci_Position lineCurrent = styler.GetLine(startPos); bool apostropheStartsAttribute = (styler.GetLineState(lineCurrent) & 1) != 0; while (sc.More()) { diff --git a/src/stc/scintilla/lexers/LexAsm.cxx b/src/stc/scintilla/lexers/LexAsm.cxx index 37a4efe357..0b8e438a8f 100644 --- a/src/stc/scintilla/lexers/LexAsm.cxx +++ b/src/stc/scintilla/lexers/LexAsm.cxx @@ -172,13 +172,13 @@ public: const char * SCI_METHOD DescribeProperty(const char *name) { return osAsm.DescribeProperty(name); } - int SCI_METHOD PropertySet(const char *key, const char *val); + Sci_Position SCI_METHOD PropertySet(const char *key, const char *val); const char * SCI_METHOD DescribeWordListSets() { return osAsm.DescribeWordListSets(); } - int SCI_METHOD WordListSet(int n, const char *wl); - void SCI_METHOD Lex(unsigned int startPos, int length, int initStyle, IDocument *pAccess); - void SCI_METHOD Fold(unsigned int startPos, int length, int initStyle, IDocument *pAccess); + Sci_Position SCI_METHOD WordListSet(int n, const char *wl); + void SCI_METHOD Lex(Sci_PositionU startPos, Sci_Position length, int initStyle, IDocument *pAccess); + void SCI_METHOD Fold(Sci_PositionU startPos, Sci_Position length, int initStyle, IDocument *pAccess); void * SCI_METHOD PrivateCall(int, void *) { return 0; @@ -193,14 +193,14 @@ public: } }; -int SCI_METHOD LexerAsm::PropertySet(const char *key, const char *val) { +Sci_Position SCI_METHOD LexerAsm::PropertySet(const char *key, const char *val) { if (osAsm.PropertySet(&options, key, val)) { return 0; } return -1; } -int SCI_METHOD LexerAsm::WordListSet(int n, const char *wl) { +Sci_Position SCI_METHOD LexerAsm::WordListSet(int n, const char *wl) { WordList *wordListN = 0; switch (n) { case 0: @@ -228,7 +228,7 @@ int SCI_METHOD LexerAsm::WordListSet(int n, const char *wl) { wordListN = &directives4foldend; break; } - int firstModification = -1; + Sci_Position firstModification = -1; if (wordListN) { WordList wlNew; wlNew.Set(wl); @@ -240,7 +240,7 @@ int SCI_METHOD LexerAsm::WordListSet(int n, const char *wl) { return firstModification; } -void SCI_METHOD LexerAsm::Lex(unsigned int startPos, int length, int initStyle, IDocument *pAccess) { +void SCI_METHOD LexerAsm::Lex(Sci_PositionU startPos, Sci_Position length, int initStyle, IDocument *pAccess) { LexAccessor styler(pAccess); // Do not leak onto next line @@ -371,16 +371,16 @@ void SCI_METHOD LexerAsm::Lex(unsigned int startPos, int length, int initStyle, // level store to make it easy to pick up with each increment // and to make it possible to fiddle the current level for "else". -void SCI_METHOD LexerAsm::Fold(unsigned int startPos, int length, int initStyle, IDocument *pAccess) { +void SCI_METHOD LexerAsm::Fold(Sci_PositionU startPos, Sci_Position length, int initStyle, IDocument *pAccess) { if (!options.fold) return; LexAccessor styler(pAccess); - unsigned int endPos = startPos + length; + Sci_PositionU endPos = startPos + length; int visibleChars = 0; - int lineCurrent = styler.GetLine(startPos); + Sci_Position lineCurrent = styler.GetLine(startPos); int levelCurrent = SC_FOLDLEVELBASE; if (lineCurrent > 0) levelCurrent = styler.LevelAt(lineCurrent-1) >> 16; @@ -391,7 +391,7 @@ void SCI_METHOD LexerAsm::Fold(unsigned int startPos, int length, int initStyle, char word[100]; int wordlen = 0; const bool userDefinedFoldMarkers = !options.foldExplicitStart.empty() && !options.foldExplicitEnd.empty(); - for (unsigned int i = startPos; i < endPos; i++) { + for (Sci_PositionU i = startPos; i < endPos; i++) { char ch = chNext; chNext = styler.SafeGetCharAt(i + 1); int stylePrev = style; @@ -453,7 +453,7 @@ void SCI_METHOD LexerAsm::Fold(unsigned int startPos, int length, int initStyle, } lineCurrent++; levelCurrent = levelNext; - if (atEOL && (i == static_cast(styler.Length()-1))) { + if (atEOL && (i == static_cast(styler.Length() - 1))) { // There is an empty line at end of file so give it same level and empty styler.SetLevel(lineCurrent, (levelCurrent | levelCurrent << 16) | SC_FOLDLEVELWHITEFLAG); } diff --git a/src/stc/scintilla/lexers/LexAsn1.cxx b/src/stc/scintilla/lexers/LexAsn1.cxx index 120b8954b9..7c5f48e75d 100644 --- a/src/stc/scintilla/lexers/LexAsn1.cxx +++ b/src/stc/scintilla/lexers/LexAsn1.cxx @@ -47,7 +47,7 @@ static bool isAsn1Char(int ch) // Function determining the color of a given code portion // Based on a "state" // -static void ColouriseAsn1Doc(unsigned int startPos, int length, int initStyle, WordList *keywordLists[], Accessor &styler) +static void ColouriseAsn1Doc(Sci_PositionU startPos, Sci_Position length, int initStyle, WordList *keywordLists[], Accessor &styler) { // The keywords WordList &Keywords = *keywordLists[0]; @@ -168,7 +168,7 @@ asn1_default: sc.Complete(); } -static void FoldAsn1Doc(unsigned int, int, int, WordList *[], Accessor &styler) +static void FoldAsn1Doc(Sci_PositionU, Sci_Position, int, WordList *[], Accessor &styler) { // No folding enabled, no reason to continue... if( styler.GetPropertyInt("fold") == 0 ) diff --git a/src/stc/scintilla/lexers/LexBaan.cxx b/src/stc/scintilla/lexers/LexBaan.cxx index 3784f3c310..8da2f3a3e7 100644 --- a/src/stc/scintilla/lexers/LexBaan.cxx +++ b/src/stc/scintilla/lexers/LexBaan.cxx @@ -36,7 +36,7 @@ static inline bool IsAWordStart(const int ch) { return (ch < 0x80) && (isalnum(ch) || ch == '_'); } -static void ColouriseBaanDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[], +static void ColouriseBaanDoc(Sci_PositionU startPos, Sci_Position length, int initStyle, WordList *keywordlists[], Accessor &styler) { WordList &keywords = *keywordlists[0]; @@ -137,19 +137,19 @@ static void ColouriseBaanDoc(unsigned int startPos, int length, int initStyle, W sc.Complete(); } -static void FoldBaanDoc(unsigned int startPos, int length, int initStyle, WordList *[], +static void FoldBaanDoc(Sci_PositionU startPos, Sci_Position length, int initStyle, WordList *[], Accessor &styler) { bool foldComment = styler.GetPropertyInt("fold.comment") != 0; bool foldCompact = styler.GetPropertyInt("fold.compact", 1) != 0; - unsigned int endPos = startPos + length; + Sci_PositionU endPos = startPos + length; int visibleChars = 0; - int lineCurrent = styler.GetLine(startPos); + Sci_Position lineCurrent = styler.GetLine(startPos); int levelPrev = styler.LevelAt(lineCurrent) & SC_FOLDLEVELNUMBERMASK; int levelCurrent = levelPrev; char chNext = styler[startPos]; int styleNext = styler.StyleAt(startPos); int style = initStyle; - for (unsigned int i = startPos; i < endPos; i++) { + for (Sci_PositionU i = startPos; i < endPos; i++) { char ch = chNext; chNext = styler.SafeGetCharAt(i + 1); int stylePrev = style; diff --git a/src/stc/scintilla/lexers/LexBash.cxx b/src/stc/scintilla/lexers/LexBash.cxx index a5f0f6e695..af8507d7de 100644 --- a/src/stc/scintilla/lexers/LexBash.cxx +++ b/src/stc/scintilla/lexers/LexBash.cxx @@ -96,7 +96,20 @@ static int opposite(int ch) { return ch; } -static void ColouriseBashDoc(unsigned int startPos, int length, int initStyle, +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) { WordList &keywords = *keywordlists[0]; @@ -113,9 +126,9 @@ static void ColouriseBashDoc(unsigned int startPos, int length, int initStyle, CharacterSet setBashOperator(CharacterSet::setNone, "^&%()-+=|{}[]:;>,*/ 0 && startPos == static_cast(styler.LineStart(ln))) + Sci_Position ln = styler.GetLine(startPos); + if (ln > 0 && startPos == static_cast(styler.LineStart(ln))) ln--; for (;;) { startPos = styler.LineStart(ln); @@ -345,6 +350,8 @@ static void ColouriseBashDoc(unsigned int startPos, int length, int initStyle, sc.ForwardSetState(SCE_SH_DEFAULT); } else if (!setWord.Contains(sc.ch)) { sc.SetState(SCE_SH_DEFAULT); + } else if (cmdState == BASH_CMD_ARITH && !setWordStart.Contains(sc.ch)) { + sc.SetState(SCE_SH_DEFAULT); } break; case SCE_SH_NUMBER: @@ -419,17 +426,18 @@ static void ColouriseBashDoc(unsigned int startPos, int length, int initStyle, sc.Forward(); HereDoc.Quoted = true; HereDoc.State = 1; - } else if (setHereDoc.Contains(sc.chNext)) { + } else if (setHereDoc.Contains(sc.chNext) || + (sc.chNext == '=' && cmdState != BASH_CMD_ARITH)) { // an unquoted here-doc delimiter, no special handling - // TODO check what exactly bash considers part of the delim HereDoc.State = 1; } else if (sc.chNext == '<') { // HERE string <<< sc.Forward(); sc.ForwardSetState(SCE_SH_DEFAULT); } else if (IsASpace(sc.chNext)) { // eat whitespace - } else if (setLeftShift.Contains(sc.chNext)) { - // left shift << or <<= operator cases + } else if (setLeftShift.Contains(sc.chNext) || + (sc.chNext == '=' && cmdState == BASH_CMD_ARITH)) { + // left shift <<$var or <<= cases sc.ChangeState(SCE_SH_OPERATOR); sc.ForwardSetState(SCE_SH_DEFAULT); } else { @@ -584,12 +592,14 @@ static void ColouriseBashDoc(unsigned int startPos, int length, int initStyle, HereDoc.State = 2; if (HereDoc.Quoted) { if (sc.state == SCE_SH_HERE_DELIM) { - // Missing quote at end of string! We are stricter than bash. - // Colour here-doc anyway while marking this bit as an error. + // Missing quote at end of string! Syntax error in bash 4.3 + // Mark this bit as an error, do not colour any here-doc sc.ChangeState(SCE_SH_ERROR); + sc.SetState(SCE_SH_DEFAULT); + } else { + // HereDoc.Quote always == '\'' + sc.SetState(SCE_SH_HERE_Q); } - // HereDoc.Quote always == '\'' - sc.SetState(SCE_SH_HERE_Q); } else if (HereDoc.DelimiterLength == 0) { // no delimiter, illegal (but '' and "" are legal) sc.ChangeState(SCE_SH_ERROR); @@ -634,6 +644,23 @@ static void ColouriseBashDoc(unsigned int startPos, int length, int initStyle, } else { sc.SetState(SCE_SH_WORD); } + // handle some zsh features within arithmetic expressions only + if (cmdState == BASH_CMD_ARITH) { + if (sc.chPrev == '[') { // [#8] [##8] output digit setting + sc.SetState(SCE_SH_WORD); + if (sc.chNext == '#') { + sc.Forward(); + } + } else if (sc.Match("##^") && IsUpperCase(sc.GetRelative(3))) { // ##^A + sc.SetState(SCE_SH_IDENTIFIER); + sc.Forward(3); + } else if (sc.chNext == '#' && !IsASpace(sc.GetRelative(2))) { // ##a + sc.SetState(SCE_SH_IDENTIFIER); + sc.Forward(2); + } else if (setWordStart.Contains(sc.chNext)) { // #name + sc.SetState(SCE_SH_IDENTIFIER); + } + } } else if (sc.ch == '\"') { sc.SetState(SCE_SH_STRING); QuoteStack.Start(sc.ch, BASH_DELIM_STRING); @@ -687,6 +714,15 @@ static void ColouriseBashDoc(unsigned int startPos, int length, int initStyle, char s[10]; bool isCmdDelim = false; sc.SetState(SCE_SH_OPERATOR); + // globs have no whitespace, do not appear in arithmetic expressions + if (cmdState != BASH_CMD_ARITH && sc.ch == '(' && sc.chNext != '(') { + int i = GlobScan(sc); + if (i > 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) { @@ -752,10 +788,10 @@ static void ColouriseBashDoc(unsigned int startPos, int length, int initStyle, sc.Complete(); } -static bool IsCommentLine(int line, Accessor &styler) { - int pos = styler.LineStart(line); - int eol_pos = styler.LineStart(line + 1) - 1; - for (int i = pos; i < eol_pos; i++) { +static bool IsCommentLine(Sci_Position line, Accessor &styler) { + Sci_Position pos = styler.LineStart(line); + Sci_Position eol_pos = styler.LineStart(line + 1) - 1; + for (Sci_Position i = pos; i < eol_pos; i++) { char ch = styler[i]; if (ch == '#') return true; @@ -765,19 +801,19 @@ static bool IsCommentLine(int line, Accessor &styler) { return false; } -static void FoldBashDoc(unsigned int startPos, int length, int, WordList *[], +static void FoldBashDoc(Sci_PositionU startPos, Sci_Position length, int, WordList *[], Accessor &styler) { bool foldComment = styler.GetPropertyInt("fold.comment") != 0; bool foldCompact = styler.GetPropertyInt("fold.compact", 1) != 0; - unsigned int endPos = startPos + length; + Sci_PositionU endPos = startPos + length; int visibleChars = 0; int skipHereCh = 0; - int lineCurrent = styler.GetLine(startPos); + Sci_Position lineCurrent = styler.GetLine(startPos); int levelPrev = styler.LevelAt(lineCurrent) & SC_FOLDLEVELNUMBERMASK; int levelCurrent = levelPrev; char chNext = styler[startPos]; int styleNext = styler.StyleAt(startPos); - for (unsigned int i = startPos; i < endPos; i++) { + for (Sci_PositionU i = startPos; i < endPos; i++) { char ch = chNext; chNext = styler.SafeGetCharAt(i + 1); int style = styleNext; diff --git a/src/stc/scintilla/lexers/LexBasic.cxx b/src/stc/scintilla/lexers/LexBasic.cxx index b73fac8b6e..7fa5b5498b 100644 --- a/src/stc/scintilla/lexers/LexBasic.cxx +++ b/src/stc/scintilla/lexers/LexBasic.cxx @@ -255,13 +255,13 @@ public: const char * SCI_METHOD DescribeProperty(const char *name) { return osBasic.DescribeProperty(name); } - int SCI_METHOD PropertySet(const char *key, const char *val); + Sci_Position SCI_METHOD PropertySet(const char *key, const char *val); const char * SCI_METHOD DescribeWordListSets() { return osBasic.DescribeWordListSets(); } - int SCI_METHOD WordListSet(int n, const char *wl); - void SCI_METHOD Lex(unsigned int startPos, int length, int initStyle, IDocument *pAccess); - void SCI_METHOD Fold(unsigned int startPos, int length, int initStyle, IDocument *pAccess); + Sci_Position SCI_METHOD WordListSet(int n, const char *wl); + void SCI_METHOD Lex(Sci_PositionU startPos, Sci_Position length, int initStyle, IDocument *pAccess); + void SCI_METHOD Fold(Sci_PositionU startPos, Sci_Position length, int initStyle, IDocument *pAccess); void * SCI_METHOD PrivateCall(int, void *) { return 0; @@ -277,14 +277,14 @@ public: } }; -int SCI_METHOD LexerBasic::PropertySet(const char *key, const char *val) { +Sci_Position SCI_METHOD LexerBasic::PropertySet(const char *key, const char *val) { if (osBasic.PropertySet(&options, key, val)) { return 0; } return -1; } -int SCI_METHOD LexerBasic::WordListSet(int n, const char *wl) { +Sci_Position SCI_METHOD LexerBasic::WordListSet(int n, const char *wl) { WordList *wordListN = 0; switch (n) { case 0: @@ -300,7 +300,7 @@ int SCI_METHOD LexerBasic::WordListSet(int n, const char *wl) { wordListN = &keywordlists[3]; break; } - int firstModification = -1; + Sci_Position firstModification = -1; if (wordListN) { WordList wlNew; wlNew.Set(wl); @@ -312,7 +312,7 @@ int SCI_METHOD LexerBasic::WordListSet(int n, const char *wl) { return firstModification; } -void SCI_METHOD LexerBasic::Lex(unsigned int startPos, int length, int initStyle, IDocument *pAccess) { +void SCI_METHOD LexerBasic::Lex(Sci_PositionU startPos, Sci_Position length, int initStyle, IDocument *pAccess) { LexAccessor styler(pAccess); bool wasfirst = true, isfirst = true; // true if first token in a line @@ -471,17 +471,17 @@ void SCI_METHOD LexerBasic::Lex(unsigned int startPos, int length, int initStyle } -void SCI_METHOD LexerBasic::Fold(unsigned int startPos, int length, int /* initStyle */, IDocument *pAccess) { +void SCI_METHOD LexerBasic::Fold(Sci_PositionU startPos, Sci_Position length, int /* initStyle */, IDocument *pAccess) { if (!options.fold) return; LexAccessor styler(pAccess); - int line = styler.GetLine(startPos); + Sci_Position line = styler.GetLine(startPos); int level = styler.LevelAt(line); int go = 0, done = 0; - int endPos = startPos + length; + Sci_Position endPos = startPos + length; char word[256]; int wordlen = 0; const bool userDefinedFoldMarkers = !options.foldExplicitStart.empty() && !options.foldExplicitEnd.empty(); @@ -489,7 +489,7 @@ void SCI_METHOD LexerBasic::Fold(unsigned int startPos, int length, int /* initS // Scan for tokens at the start of the line (they may include // whitespace, for tokens like "End Function" - for (int i = startPos; i < endPos; i++) { + for (Sci_Position i = startPos; i < endPos; i++) { int c = cNext; cNext = styler.SafeGetCharAt(i + 1); bool atEOL = (c == '\r' && cNext != '\n') || (c == '\n'); diff --git a/src/stc/scintilla/lexers/LexBatch.cxx b/src/stc/scintilla/lexers/LexBatch.cxx new file mode 100644 index 0000000000..377b2cbf1e --- /dev/null +++ b/src/stc/scintilla/lexers/LexBatch.cxx @@ -0,0 +1,500 @@ +// Scintilla source code edit control +/** @file LexBatch.cxx + ** Lexer for batch files. + **/ +// Copyright 1998-2001 by Neil Hodgson +// The License.txt file describes the conditions under which this software may be distributed. + +#include +#include +#include +#include +#include +#include + +#include "ILexer.h" +#include "Scintilla.h" +#include "SciLexer.h" + +#include "WordList.h" +#include "LexAccessor.h" +#include "Accessor.h" +#include "StyleContext.h" +#include "CharacterSet.h" +#include "LexerModule.h" + +#ifdef SCI_NAMESPACE +using namespace Scintilla; +#endif + +static bool Is0To9(char ch) { + return (ch >= '0') && (ch <= '9'); +} + +static bool IsAlphabetic(int ch) { + return IsASCII(ch) && isalpha(ch); +} + +static inline bool AtEOL(Accessor &styler, Sci_PositionU i) { + return (styler[i] == '\n') || + ((styler[i] == '\r') && (styler.SafeGetCharAt(i + 1) != '\n')); +} + +// Tests for BATCH Operators +static bool IsBOperator(char ch) { + return (ch == '=') || (ch == '+') || (ch == '>') || (ch == '<') || + (ch == '|') || (ch == '?') || (ch == '*'); +} + +// Tests for BATCH Separators +static bool IsBSeparator(char ch) { + return (ch == '\\') || (ch == '.') || (ch == ';') || + (ch == '\"') || (ch == '\'') || (ch == '/'); +} + +static void ColouriseBatchLine( + char *lineBuffer, + Sci_PositionU lengthLine, + Sci_PositionU startLine, + Sci_PositionU endPos, + WordList *keywordlists[], + Accessor &styler) { + + Sci_PositionU offset = 0; // Line Buffer Offset + Sci_PositionU cmdLoc; // External Command / Program Location + char wordBuffer[81]; // Word Buffer - large to catch long paths + Sci_PositionU wbl; // Word Buffer Length + Sci_PositionU wbo; // Word Buffer Offset - also Special Keyword Buffer Length + WordList &keywords = *keywordlists[0]; // Internal Commands + WordList &keywords2 = *keywordlists[1]; // External Commands (optional) + + // CHOICE, ECHO, GOTO, PROMPT and SET have Default Text that may contain Regular Keywords + // Toggling Regular Keyword Checking off improves readability + // Other Regular Keywords and External Commands / Programs might also benefit from toggling + // Need a more robust algorithm to properly toggle Regular Keyword Checking + bool continueProcessing = true; // Used to toggle Regular Keyword Checking + // Special Keywords are those that allow certain characters without whitespace after the command + // Examples are: cd. cd\ md. rd. dir| dir> echo: echo. path= + // Special Keyword Buffer used to determine if the first n characters is a Keyword + char sKeywordBuffer[10]; // Special Keyword Buffer + bool sKeywordFound; // Exit Special Keyword for-loop if found + + // Skip initial spaces + while ((offset < lengthLine) && (isspacechar(lineBuffer[offset]))) { + offset++; + } + // Colorize Default Text + styler.ColourTo(startLine + offset - 1, SCE_BAT_DEFAULT); + // Set External Command / Program Location + cmdLoc = offset; + + // Check for Fake Label (Comment) or Real Label - return if found + if (lineBuffer[offset] == ':') { + if (lineBuffer[offset + 1] == ':') { + // Colorize Fake Label (Comment) - :: is similar to REM, see http://content.techweb.com/winmag/columns/explorer/2000/21.htm + styler.ColourTo(endPos, SCE_BAT_COMMENT); + } else { + // Colorize Real Label + styler.ColourTo(endPos, SCE_BAT_LABEL); + } + return; + // Check for Drive Change (Drive Change is internal command) - return if found + } else if ((IsAlphabetic(lineBuffer[offset])) && + (lineBuffer[offset + 1] == ':') && + ((isspacechar(lineBuffer[offset + 2])) || + (((lineBuffer[offset + 2] == '\\')) && + (isspacechar(lineBuffer[offset + 3]))))) { + // Colorize Regular Keyword + styler.ColourTo(endPos, SCE_BAT_WORD); + return; + } + + // Check for Hide Command (@ECHO OFF/ON) + if (lineBuffer[offset] == '@') { + styler.ColourTo(startLine + offset, SCE_BAT_HIDE); + offset++; + } + // Skip next spaces + while ((offset < lengthLine) && (isspacechar(lineBuffer[offset]))) { + offset++; + } + + // Read remainder of line word-at-a-time or remainder-of-word-at-a-time + while (offset < lengthLine) { + if (offset > startLine) { + // Colorize Default Text + styler.ColourTo(startLine + offset - 1, SCE_BAT_DEFAULT); + } + // Copy word from Line Buffer into Word Buffer + wbl = 0; + for (; offset < lengthLine && wbl < 80 && + !isspacechar(lineBuffer[offset]); wbl++, offset++) { + wordBuffer[wbl] = static_cast(tolower(lineBuffer[offset])); + } + wordBuffer[wbl] = '\0'; + wbo = 0; + + // Check for Comment - return if found + if (CompareCaseInsensitive(wordBuffer, "rem") == 0) { + styler.ColourTo(endPos, SCE_BAT_COMMENT); + return; + } + // Check for Separator + if (IsBSeparator(wordBuffer[0])) { + // Check for External Command / Program + if ((cmdLoc == offset - wbl) && + ((wordBuffer[0] == ':') || + (wordBuffer[0] == '\\') || + (wordBuffer[0] == '.'))) { + // Reset Offset to re-process remainder of word + offset -= (wbl - 1); + // Colorize External Command / Program + if (!keywords2) { + styler.ColourTo(startLine + offset - 1, SCE_BAT_COMMAND); + } else if (keywords2.InList(wordBuffer)) { + styler.ColourTo(startLine + offset - 1, SCE_BAT_COMMAND); + } else { + styler.ColourTo(startLine + offset - 1, SCE_BAT_DEFAULT); + } + // Reset External Command / Program Location + cmdLoc = offset; + } else { + // Reset Offset to re-process remainder of word + offset -= (wbl - 1); + // Colorize Default Text + styler.ColourTo(startLine + offset - 1, SCE_BAT_DEFAULT); + } + // Check for Regular Keyword in list + } else if ((keywords.InList(wordBuffer)) && + (continueProcessing)) { + // ECHO, GOTO, PROMPT and SET require no further Regular Keyword Checking + if ((CompareCaseInsensitive(wordBuffer, "echo") == 0) || + (CompareCaseInsensitive(wordBuffer, "goto") == 0) || + (CompareCaseInsensitive(wordBuffer, "prompt") == 0) || + (CompareCaseInsensitive(wordBuffer, "set") == 0)) { + continueProcessing = false; + } + // Identify External Command / Program Location for ERRORLEVEL, and EXIST + if ((CompareCaseInsensitive(wordBuffer, "errorlevel") == 0) || + (CompareCaseInsensitive(wordBuffer, "exist") == 0)) { + // Reset External Command / Program Location + cmdLoc = offset; + // Skip next spaces + while ((cmdLoc < lengthLine) && + (isspacechar(lineBuffer[cmdLoc]))) { + cmdLoc++; + } + // Skip comparison + while ((cmdLoc < lengthLine) && + (!isspacechar(lineBuffer[cmdLoc]))) { + cmdLoc++; + } + // Skip next spaces + while ((cmdLoc < lengthLine) && + (isspacechar(lineBuffer[cmdLoc]))) { + cmdLoc++; + } + // Identify External Command / Program Location for CALL, DO, LOADHIGH and LH + } else if ((CompareCaseInsensitive(wordBuffer, "call") == 0) || + (CompareCaseInsensitive(wordBuffer, "do") == 0) || + (CompareCaseInsensitive(wordBuffer, "loadhigh") == 0) || + (CompareCaseInsensitive(wordBuffer, "lh") == 0)) { + // Reset External Command / Program Location + cmdLoc = offset; + // Skip next spaces + while ((cmdLoc < lengthLine) && + (isspacechar(lineBuffer[cmdLoc]))) { + cmdLoc++; + } + } + // Colorize Regular keyword + styler.ColourTo(startLine + offset - 1, SCE_BAT_WORD); + // No need to Reset Offset + // Check for Special Keyword in list, External Command / Program, or Default Text + } else if ((wordBuffer[0] != '%') && + (wordBuffer[0] != '!') && + (!IsBOperator(wordBuffer[0])) && + (continueProcessing)) { + // Check for Special Keyword + // Affected Commands are in Length range 2-6 + // Good that ERRORLEVEL, EXIST, CALL, DO, LOADHIGH, and LH are unaffected + sKeywordFound = false; + for (Sci_PositionU keywordLength = 2; keywordLength < wbl && keywordLength < 7 && !sKeywordFound; keywordLength++) { + wbo = 0; + // Copy Keyword Length from Word Buffer into Special Keyword Buffer + for (; wbo < keywordLength; wbo++) { + sKeywordBuffer[wbo] = static_cast(wordBuffer[wbo]); + } + sKeywordBuffer[wbo] = '\0'; + // Check for Special Keyword in list + if ((keywords.InList(sKeywordBuffer)) && + ((IsBOperator(wordBuffer[wbo])) || + (IsBSeparator(wordBuffer[wbo])))) { + sKeywordFound = true; + // ECHO requires no further Regular Keyword Checking + if (CompareCaseInsensitive(sKeywordBuffer, "echo") == 0) { + continueProcessing = false; + } + // Colorize Special Keyword as Regular Keyword + styler.ColourTo(startLine + offset - 1 - (wbl - wbo), SCE_BAT_WORD); + // Reset Offset to re-process remainder of word + offset -= (wbl - wbo); + } + } + // Check for External Command / Program or Default Text + if (!sKeywordFound) { + wbo = 0; + // Check for External Command / Program + if (cmdLoc == offset - wbl) { + // Read up to %, Operator or Separator + while ((wbo < wbl) && + (wordBuffer[wbo] != '%') && + (wordBuffer[wbo] != '!') && + (!IsBOperator(wordBuffer[wbo])) && + (!IsBSeparator(wordBuffer[wbo]))) { + wbo++; + } + // Reset External Command / Program Location + cmdLoc = offset - (wbl - wbo); + // Reset Offset to re-process remainder of word + offset -= (wbl - wbo); + // CHOICE requires no further Regular Keyword Checking + if (CompareCaseInsensitive(wordBuffer, "choice") == 0) { + continueProcessing = false; + } + // Check for START (and its switches) - What follows is External Command \ Program + if (CompareCaseInsensitive(wordBuffer, "start") == 0) { + // Reset External Command / Program Location + cmdLoc = offset; + // Skip next spaces + while ((cmdLoc < lengthLine) && + (isspacechar(lineBuffer[cmdLoc]))) { + cmdLoc++; + } + // Reset External Command / Program Location if command switch detected + if (lineBuffer[cmdLoc] == '/') { + // Skip command switch + while ((cmdLoc < lengthLine) && + (!isspacechar(lineBuffer[cmdLoc]))) { + cmdLoc++; + } + // Skip next spaces + while ((cmdLoc < lengthLine) && + (isspacechar(lineBuffer[cmdLoc]))) { + cmdLoc++; + } + } + } + // Colorize External Command / Program + if (!keywords2) { + styler.ColourTo(startLine + offset - 1, SCE_BAT_COMMAND); + } else if (keywords2.InList(wordBuffer)) { + styler.ColourTo(startLine + offset - 1, SCE_BAT_COMMAND); + } else { + styler.ColourTo(startLine + offset - 1, SCE_BAT_DEFAULT); + } + // No need to Reset Offset + // Check for Default Text + } else { + // Read up to %, Operator or Separator + while ((wbo < wbl) && + (wordBuffer[wbo] != '%') && + (wordBuffer[wbo] != '!') && + (!IsBOperator(wordBuffer[wbo])) && + (!IsBSeparator(wordBuffer[wbo]))) { + wbo++; + } + // Colorize Default Text + styler.ColourTo(startLine + offset - 1 - (wbl - wbo), SCE_BAT_DEFAULT); + // Reset Offset to re-process remainder of word + offset -= (wbl - wbo); + } + } + // Check for Argument (%n), Environment Variable (%x...%) or Local Variable (%%a) + } else if (wordBuffer[0] == '%') { + // Colorize Default Text + styler.ColourTo(startLine + offset - 1 - wbl, SCE_BAT_DEFAULT); + wbo++; + // Search to end of word for second % (can be a long path) + while ((wbo < wbl) && + (wordBuffer[wbo] != '%') && + (!IsBOperator(wordBuffer[wbo])) && + (!IsBSeparator(wordBuffer[wbo]))) { + wbo++; + } + // Check for Argument (%n) or (%*) + if (((Is0To9(wordBuffer[1])) || (wordBuffer[1] == '*')) && + (wordBuffer[wbo] != '%')) { + // Check for External Command / Program + if (cmdLoc == offset - wbl) { + cmdLoc = offset - (wbl - 2); + } + // Colorize Argument + styler.ColourTo(startLine + offset - 1 - (wbl - 2), SCE_BAT_IDENTIFIER); + // Reset Offset to re-process remainder of word + offset -= (wbl - 2); + // Check for Expanded Argument (%~...) / Variable (%%~...) + } else if (((wbl > 1) && (wordBuffer[1] == '~')) || + ((wbl > 2) && (wordBuffer[1] == '%') && (wordBuffer[2] == '~'))) { + // Check for External Command / Program + if (cmdLoc == offset - wbl) { + cmdLoc = offset - (wbl - wbo); + } + // Colorize Expanded Argument / Variable + styler.ColourTo(startLine + offset - 1 - (wbl - wbo), SCE_BAT_IDENTIFIER); + // Reset Offset to re-process remainder of word + offset -= (wbl - wbo); + // Check for Environment Variable (%x...%) + } else if ((wordBuffer[1] != '%') && + (wordBuffer[wbo] == '%')) { + wbo++; + // Check for External Command / Program + if (cmdLoc == offset - wbl) { + cmdLoc = offset - (wbl - wbo); + } + // Colorize Environment Variable + styler.ColourTo(startLine + offset - 1 - (wbl - wbo), SCE_BAT_IDENTIFIER); + // Reset Offset to re-process remainder of word + offset -= (wbl - wbo); + // Check for Local Variable (%%a) + } else if ( + (wbl > 2) && + (wordBuffer[1] == '%') && + (wordBuffer[2] != '%') && + (!IsBOperator(wordBuffer[2])) && + (!IsBSeparator(wordBuffer[2]))) { + // Check for External Command / Program + if (cmdLoc == offset - wbl) { + cmdLoc = offset - (wbl - 3); + } + // Colorize Local Variable + styler.ColourTo(startLine + offset - 1 - (wbl - 3), SCE_BAT_IDENTIFIER); + // Reset Offset to re-process remainder of word + offset -= (wbl - 3); + } + // Check for Environment Variable (!x...!) + } else if (wordBuffer[0] == '!') { + // Colorize Default Text + styler.ColourTo(startLine + offset - 1 - wbl, SCE_BAT_DEFAULT); + wbo++; + // Search to end of word for second ! (can be a long path) + while ((wbo < wbl) && + (wordBuffer[wbo] != '!') && + (!IsBOperator(wordBuffer[wbo])) && + (!IsBSeparator(wordBuffer[wbo]))) { + wbo++; + } + if (wordBuffer[wbo] == '!') { + wbo++; + // Check for External Command / Program + if (cmdLoc == offset - wbl) { + cmdLoc = offset - (wbl - wbo); + } + // Colorize Environment Variable + styler.ColourTo(startLine + offset - 1 - (wbl - wbo), SCE_BAT_IDENTIFIER); + // Reset Offset to re-process remainder of word + offset -= (wbl - wbo); + } + // Check for Operator + } else if (IsBOperator(wordBuffer[0])) { + // Colorize Default Text + styler.ColourTo(startLine + offset - 1 - wbl, SCE_BAT_DEFAULT); + // Check for Comparison Operator + if ((wordBuffer[0] == '=') && (wordBuffer[1] == '=')) { + // Identify External Command / Program Location for IF + cmdLoc = offset; + // Skip next spaces + while ((cmdLoc < lengthLine) && + (isspacechar(lineBuffer[cmdLoc]))) { + cmdLoc++; + } + // Colorize Comparison Operator + styler.ColourTo(startLine + offset - 1 - (wbl - 2), SCE_BAT_OPERATOR); + // Reset Offset to re-process remainder of word + offset -= (wbl - 2); + // Check for Pipe Operator + } else if (wordBuffer[0] == '|') { + // Reset External Command / Program Location + cmdLoc = offset - wbl + 1; + // Skip next spaces + while ((cmdLoc < lengthLine) && + (isspacechar(lineBuffer[cmdLoc]))) { + cmdLoc++; + } + // Colorize Pipe Operator + styler.ColourTo(startLine + offset - 1 - (wbl - 1), SCE_BAT_OPERATOR); + // Reset Offset to re-process remainder of word + offset -= (wbl - 1); + // Check for Other Operator + } else { + // Check for > Operator + if (wordBuffer[0] == '>') { + // Turn Keyword and External Command / Program checking back on + continueProcessing = true; + } + // Colorize Other Operator + styler.ColourTo(startLine + offset - 1 - (wbl - 1), SCE_BAT_OPERATOR); + // Reset Offset to re-process remainder of word + offset -= (wbl - 1); + } + // Check for Default Text + } else { + // Read up to %, Operator or Separator + while ((wbo < wbl) && + (wordBuffer[wbo] != '%') && + (wordBuffer[wbo] != '!') && + (!IsBOperator(wordBuffer[wbo])) && + (!IsBSeparator(wordBuffer[wbo]))) { + wbo++; + } + // Colorize Default Text + styler.ColourTo(startLine + offset - 1 - (wbl - wbo), SCE_BAT_DEFAULT); + // Reset Offset to re-process remainder of word + offset -= (wbl - wbo); + } + // Skip next spaces - nothing happens if Offset was Reset + while ((offset < lengthLine) && (isspacechar(lineBuffer[offset]))) { + offset++; + } + } + // Colorize Default Text for remainder of line - currently not lexed + styler.ColourTo(endPos, SCE_BAT_DEFAULT); +} + +static void ColouriseBatchDoc( + Sci_PositionU startPos, + Sci_Position length, + int /*initStyle*/, + WordList *keywordlists[], + Accessor &styler) { + + char lineBuffer[1024]; + + styler.StartAt(startPos); + styler.StartSegment(startPos); + Sci_PositionU linePos = 0; + Sci_PositionU startLine = startPos; + for (Sci_PositionU i = startPos; i < startPos + length; i++) { + lineBuffer[linePos++] = styler[i]; + if (AtEOL(styler, i) || (linePos >= sizeof(lineBuffer) - 1)) { + // End of line (or of line buffer) met, colourise it + lineBuffer[linePos] = '\0'; + ColouriseBatchLine(lineBuffer, linePos, startLine, i, keywordlists, styler); + linePos = 0; + startLine = i + 1; + } + } + if (linePos > 0) { // Last line does not have ending characters + lineBuffer[linePos] = '\0'; + ColouriseBatchLine(lineBuffer, linePos, startLine, startPos + length - 1, + keywordlists, styler); + } +} + +static const char *const batchWordListDesc[] = { + "Internal Commands", + "External Commands", + 0 +}; + +LexerModule lmBatch(SCLEX_BATCH, ColouriseBatchDoc, "batch", 0, batchWordListDesc); diff --git a/src/stc/scintilla/lexers/LexBibTeX.cxx b/src/stc/scintilla/lexers/LexBibTeX.cxx index cdbce8d493..fef58a9b0f 100644 --- a/src/stc/scintilla/lexers/LexBibTeX.cxx +++ b/src/stc/scintilla/lexers/LexBibTeX.cxx @@ -76,7 +76,7 @@ namespace { return IsEntryStart(sc.chPrev, sc.ch); } - void ColorizeBibTeX(unsigned start_pos, int length, int /*init_style*/, WordList* keywordlists[], Accessor& styler) + void ColorizeBibTeX(Sci_PositionU start_pos, Sci_Position length, int /*init_style*/, WordList* keywordlists[], Accessor& styler) { WordList &EntryNames = *keywordlists[0]; bool fold_compact = styler.GetPropertyInt("fold.compact", 1) != 0; @@ -94,7 +94,7 @@ namespace { styler.StartAt(start_pos); styler.StartSegment(start_pos); - int current_line = styler.GetLine(start_pos); + Sci_Position current_line = styler.GetLine(start_pos); int prev_level = styler.LevelAt(current_line) & SC_FOLDLEVELNUMBERMASK; int current_level = prev_level; int visible_chars = 0; @@ -153,7 +153,7 @@ namespace { sc.SetState(SCE_BIBTEX_DEFAULT); // Don't colorize the = sc.ForwardSetState(SCE_BIBTEX_VALUE); // Parameter value colorization - int start = sc.currentPos; + Sci_Position start = sc.currentPos; // We need to handle multiple situations: // 1. name"one two {three}" @@ -227,12 +227,12 @@ namespace { state = SCE_BIBTEX_DEFAULT; } - int end = sc.currentPos; + Sci_Position end = sc.currentPos; current_line = styler.GetLine(end); // We have possibly skipped some lines, so the folding levels // have to be adjusted separately - for (int i = styler.GetLine(start); i <= styler.GetLine(end); ++i) + for (Sci_Position i = styler.GetLine(start); i <= styler.GetLine(end); ++i) styler.SetLevel(i, prev_level); sc.ForwardSetState(state); diff --git a/src/stc/scintilla/lexers/LexBullant.cxx b/src/stc/scintilla/lexers/LexBullant.cxx index 51d6bd8f08..4041887699 100644 --- a/src/stc/scintilla/lexers/LexBullant.cxx +++ b/src/stc/scintilla/lexers/LexBullant.cxx @@ -23,10 +23,10 @@ using namespace Scintilla; #endif -static int classifyWordBullant(unsigned int start, unsigned int end, WordList &keywords, Accessor &styler) { +static int classifyWordBullant(Sci_PositionU start, Sci_PositionU end, WordList &keywords, Accessor &styler) { char s[100]; s[0] = '\0'; - for (unsigned int i = 0; i < end - start + 1 && i < 30; i++) { + for (Sci_PositionU i = 0; i < end - start + 1 && i < 30; i++) { s[i] = static_cast(tolower(styler[start + i])); s[i + 1] = '\0'; } @@ -58,14 +58,14 @@ static int classifyWordBullant(unsigned int start, unsigned int end, WordList &k return lev; } -static void ColouriseBullantDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[], +static void ColouriseBullantDoc(Sci_PositionU startPos, Sci_Position length, int initStyle, WordList *keywordlists[], Accessor &styler) { WordList &keywords = *keywordlists[0]; styler.StartAt(startPos); bool fold = styler.GetPropertyInt("fold") != 0; - int lineCurrent = styler.GetLine(startPos); + Sci_Position lineCurrent = styler.GetLine(startPos); int levelPrev = styler.LevelAt(lineCurrent) & SC_FOLDLEVELNUMBERMASK; int levelCurrent = levelPrev; @@ -74,11 +74,11 @@ static void ColouriseBullantDoc(unsigned int startPos, int length, int initStyle state = SCE_C_DEFAULT; char chPrev = ' '; char chNext = styler[startPos]; - unsigned int lengthDoc = startPos + length; + Sci_PositionU lengthDoc = startPos + length; int visibleChars = 0; styler.StartSegment(startPos); int endFoundThisLine = 0; - for (unsigned int i = startPos; i < lengthDoc; i++) { + for (Sci_PositionU i = startPos; i < lengthDoc; i++) { char ch = chNext; chNext = styler.SafeGetCharAt(i + 1); diff --git a/src/stc/scintilla/lexers/LexCLW.cxx b/src/stc/scintilla/lexers/LexCLW.cxx index c1dea607c3..af2ca151ad 100644 --- a/src/stc/scintilla/lexers/LexCLW.cxx +++ b/src/stc/scintilla/lexers/LexCLW.cxx @@ -142,12 +142,12 @@ inline bool SetNumericConstantState(StyleContext &scDoc) { } // Get the next word in uppercase from the current position (keyword lookahead) -inline bool GetNextWordUpper(Accessor &styler, unsigned int uiStartPos, int iLength, char *cWord) { +inline bool GetNextWordUpper(Accessor &styler, Sci_PositionU uiStartPos, Sci_Position iLength, char *cWord) { - unsigned int iIndex = 0; // Buffer Index + Sci_PositionU iIndex = 0; // Buffer Index // Loop through the remaining string from the current position - for (int iOffset = uiStartPos; iOffset < iLength; iOffset++) { + for (Sci_Position iOffset = uiStartPos; iOffset < iLength; iOffset++) { // Get the character from the buffer using the offset char cCharacter = styler[iOffset]; if (IsEOL(cCharacter)) { @@ -174,7 +174,7 @@ inline bool GetNextWordUpper(Accessor &styler, unsigned int uiStartPos, int iLen } // Clarion Language Colouring Procedure -static void ColouriseClarionDoc(unsigned int uiStartPos, int iLength, int iInitStyle, WordList *wlKeywords[], Accessor &accStyler, bool bCaseSensitive) { +static void ColouriseClarionDoc(Sci_PositionU uiStartPos, Sci_Position iLength, int iInitStyle, WordList *wlKeywords[], Accessor &accStyler, bool bCaseSensitive) { int iParenthesesLevel = 0; // Parenthese Level int iColumn1Label = false; // Label starts in Column 1 @@ -521,22 +521,22 @@ static void ColouriseClarionDoc(unsigned int uiStartPos, int iLength, int iInitS } // Clarion Language Case Sensitive Colouring Procedure -static void ColouriseClarionDocSensitive(unsigned int uiStartPos, int iLength, int iInitStyle, WordList *wlKeywords[], Accessor &accStyler) { +static void ColouriseClarionDocSensitive(Sci_PositionU uiStartPos, Sci_Position iLength, int iInitStyle, WordList *wlKeywords[], Accessor &accStyler) { ColouriseClarionDoc(uiStartPos, iLength, iInitStyle, wlKeywords, accStyler, true); } // Clarion Language Case Insensitive Colouring Procedure -static void ColouriseClarionDocInsensitive(unsigned int uiStartPos, int iLength, int iInitStyle, WordList *wlKeywords[], Accessor &accStyler) { +static void ColouriseClarionDocInsensitive(Sci_PositionU uiStartPos, Sci_Position iLength, int iInitStyle, WordList *wlKeywords[], Accessor &accStyler) { ColouriseClarionDoc(uiStartPos, iLength, iInitStyle, wlKeywords, accStyler, false); } // Fill Buffer -static void FillBuffer(unsigned int uiStart, unsigned int uiEnd, Accessor &accStyler, char *szBuffer, unsigned int uiLength) { +static void FillBuffer(Sci_PositionU uiStart, Sci_PositionU uiEnd, Accessor &accStyler, char *szBuffer, Sci_PositionU uiLength) { - unsigned int uiPos = 0; + Sci_PositionU uiPos = 0; while ((uiPos < uiEnd - uiStart + 1) && (uiPos < uiLength-1)) { szBuffer[uiPos] = static_cast(toupper(accStyler[uiStart + uiPos])); @@ -599,19 +599,19 @@ static int ClassifyClarionFoldPoint(int iLevel, const char* szString) { } // Clarion Language Folding Procedure -static void FoldClarionDoc(unsigned int uiStartPos, int iLength, int iInitStyle, WordList *[], Accessor &accStyler) { +static void FoldClarionDoc(Sci_PositionU uiStartPos, Sci_Position iLength, int iInitStyle, WordList *[], Accessor &accStyler) { - unsigned int uiEndPos = uiStartPos + iLength; - int iLineCurrent = accStyler.GetLine(uiStartPos); + Sci_PositionU uiEndPos = uiStartPos + iLength; + Sci_Position iLineCurrent = accStyler.GetLine(uiStartPos); int iLevelPrev = accStyler.LevelAt(iLineCurrent) & SC_FOLDLEVELNUMBERMASK; int iLevelCurrent = iLevelPrev; char chNext = accStyler[uiStartPos]; int iStyle = iInitStyle; int iStyleNext = accStyler.StyleAt(uiStartPos); int iVisibleChars = 0; - int iLastStart = 0; + Sci_Position iLastStart = 0; - for (unsigned int uiPos = uiStartPos; uiPos < uiEndPos; uiPos++) { + for (Sci_PositionU uiPos = uiStartPos; uiPos < uiEndPos; uiPos++) { char chChar = chNext; chNext = accStyler.SafeGetCharAt(uiPos + 1); diff --git a/src/stc/scintilla/lexers/LexCOBOL.cxx b/src/stc/scintilla/lexers/LexCOBOL.cxx index a937690d85..3150e33385 100644 --- a/src/stc/scintilla/lexers/LexCOBOL.cxx +++ b/src/stc/scintilla/lexers/LexCOBOL.cxx @@ -64,12 +64,12 @@ static int CountBits(int nBits) return count; } -static void getRange(unsigned int start, - unsigned int end, +static void getRange(Sci_PositionU start, + Sci_PositionU end, Accessor &styler, char *s, - unsigned int len) { - unsigned int i = 0; + Sci_PositionU len) { + Sci_PositionU i = 0; while ((i < end - start + 1) && (i < len-1)) { s[i] = static_cast(tolower(styler[start + i])); i++; @@ -77,12 +77,12 @@ static void getRange(unsigned int start, s[i] = '\0'; } -static void ColourTo(Accessor &styler, unsigned int end, unsigned int attr) { +static void ColourTo(Accessor &styler, Sci_PositionU end, unsigned int attr) { styler.ColourTo(end, attr); } -static int classifyWordCOBOL(unsigned int start, unsigned int end, /*WordList &keywords*/WordList *keywordlists[], Accessor &styler, int nContainment, bool *bAarea) { +static int classifyWordCOBOL(Sci_PositionU start, Sci_PositionU end, /*WordList &keywords*/WordList *keywordlists[], Accessor &styler, int nContainment, bool *bAarea) { int ret = 0; WordList& a_keywords = *keywordlists[0]; @@ -142,7 +142,7 @@ static int classifyWordCOBOL(unsigned int start, unsigned int end, /*WordList &k return ret; } -static void ColouriseCOBOLDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[], +static void ColouriseCOBOLDoc(Sci_PositionU startPos, Sci_Position length, int initStyle, WordList *keywordlists[], Accessor &styler) { styler.StartAt(startPos); @@ -152,11 +152,11 @@ static void ColouriseCOBOLDoc(unsigned int startPos, int length, int initStyle, state = SCE_C_DEFAULT; char chPrev = ' '; char chNext = styler[startPos]; - unsigned int lengthDoc = startPos + length; + Sci_PositionU lengthDoc = startPos + length; int nContainment; - int currentLine = styler.GetLine(startPos); + Sci_Position currentLine = styler.GetLine(startPos); if (currentLine > 0) { styler.SetLineState(currentLine, styler.GetLineState(currentLine-1)); nContainment = styler.GetLineState(currentLine); @@ -170,7 +170,7 @@ static void ColouriseCOBOLDoc(unsigned int startPos, int length, int initStyle, bool bNewLine = true; bool bAarea = !isspacechar(chNext); int column = 0; - for (unsigned int i = startPos; i < lengthDoc; i++) { + for (Sci_PositionU i = startPos; i < lengthDoc; i++) { char ch = chNext; chNext = styler.SafeGetCharAt(i + 1); @@ -277,7 +277,7 @@ static void ColouriseCOBOLDoc(unsigned int startPos, int length, int initStyle, if (ch == '\r' || ch == '\n') { if (((i > styler.GetStartSegment() + 2) || ( (initStyle == SCE_C_COMMENTDOC) && - (styler.GetStartSegment() == static_cast(startPos))))) { + (styler.GetStartSegment() == static_cast(startPos))))) { ColourTo(styler, i, state); state = SCE_C_DEFAULT; } @@ -309,12 +309,12 @@ static void ColouriseCOBOLDoc(unsigned int startPos, int length, int initStyle, ColourTo(styler, lengthDoc - 1, state); } -static void FoldCOBOLDoc(unsigned int startPos, int length, int, WordList *[], +static void FoldCOBOLDoc(Sci_PositionU startPos, Sci_Position length, int, WordList *[], Accessor &styler) { bool foldCompact = styler.GetPropertyInt("fold.compact", 1) != 0; - unsigned int endPos = startPos + length; + Sci_PositionU endPos = startPos + length; int visibleChars = 0; - int lineCurrent = styler.GetLine(startPos); + Sci_Position lineCurrent = styler.GetLine(startPos); int levelPrev = lineCurrent > 0 ? styler.LevelAt(lineCurrent - 1) & SC_FOLDLEVELNUMBERMASK : 0xFFF; char chNext = styler[startPos]; @@ -322,7 +322,7 @@ static void FoldCOBOLDoc(unsigned int startPos, int length, int, WordList *[], bool bAarea = !isspacechar(chNext); int column = 0; bool bComment = false; - for (unsigned int i = startPos; i < endPos; i++) { + for (Sci_PositionU i = startPos; i < endPos; i++) { char ch = chNext; chNext = styler.SafeGetCharAt(i + 1); ++column; diff --git a/src/stc/scintilla/lexers/LexCPP.cxx b/src/stc/scintilla/lexers/LexCPP.cxx index ab982bb4bb..fc9b5b86ba 100644 --- a/src/stc/scintilla/lexers/LexCPP.cxx +++ b/src/stc/scintilla/lexers/LexCPP.cxx @@ -54,7 +54,7 @@ bool IsSpaceEquiv(int state) { // Putting a space between the '++' post-inc operator and the '+' binary op // fixes this, and is highly recommended for readability anyway. bool FollowsPostfixOperator(StyleContext &sc, LexAccessor &styler) { - int pos = (int) sc.currentPos; + Sci_Position pos = (Sci_Position) sc.currentPos; while (--pos > 0) { char ch = styler[pos]; if (ch == '+' || ch == '-') { @@ -66,9 +66,9 @@ bool FollowsPostfixOperator(StyleContext &sc, LexAccessor &styler) { bool followsReturnKeyword(StyleContext &sc, LexAccessor &styler) { // Don't look at styles, so no need to flush. - int pos = (int) sc.currentPos; - int currentLine = styler.GetLine(pos); - int lineStartPos = styler.LineStart(currentLine); + Sci_Position pos = (Sci_Position) sc.currentPos; + Sci_Position currentLine = styler.GetLine(pos); + Sci_Position lineStartPos = styler.LineStart(currentLine); while (--pos > lineStartPos) { char ch = styler.SafeGetCharAt(pos); if (ch != ' ' && ch != '\t') { @@ -145,7 +145,7 @@ void highlightTaskMarker(StyleContext &sc, LexAccessor &styler, if ((isoperator(sc.chPrev) || IsASpace(sc.chPrev)) && markerList.Length()) { const int lengthMarker = 50; char marker[lengthMarker+1]; - int currPos = (int) sc.currentPos; + Sci_Position currPos = (Sci_Position) sc.currentPos; int i = 0; while (i < lengthMarker) { char ch = styler.SafeGetCharAt(currPos + i); @@ -199,11 +199,11 @@ struct EscapeSequence { } }; -std::string GetRestOfLine(LexAccessor &styler, int start, bool allowSpace) { +std::string GetRestOfLine(LexAccessor &styler, Sci_Position start, bool allowSpace) { std::string restOfLine; - int i =0; + Sci_Position i =0; char ch = styler.SafeGetCharAt(start, '\n'); - int endLine = styler.LineEnd(styler.GetLine(start)); + Sci_Position endLine = styler.LineEnd(styler.GetLine(start)); while (((start+i) < endLine) && (ch != '\r')) { char chNext = styler.SafeGetCharAt(start + i + 1, '\n'); if (ch == '/' && (chNext == '/' || chNext == '*')) @@ -224,12 +224,12 @@ bool IsStreamCommentStyle(int style) { } struct PPDefinition { - int line; + Sci_Position line; std::string key; std::string value; bool isUndef; std::string arguments; - PPDefinition(int line_, const std::string &key_, const std::string &value_, bool isUndef_ = false, std::string arguments_="") : + PPDefinition(Sci_Position line_, const std::string &key_, const std::string &value_, bool isUndef_ = false, std::string arguments_="") : line(line_), key(key_), value(value_), isUndef(isUndef_), arguments(arguments_) { } }; @@ -285,14 +285,14 @@ public: class PPStates { std::vector vlls; public: - LinePPState ForLine(int line) const { + LinePPState ForLine(Sci_Position line) const { if ((line > 0) && (vlls.size() > static_cast(line))) { return vlls[line]; } else { return LinePPState(); } } - void Add(int line, LinePPState lls) { + void Add(Sci_Position line, LinePPState lls) { vlls.resize(line+1); vlls[line] = lls; } @@ -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."); @@ -495,13 +495,13 @@ public: const char * SCI_METHOD DescribeProperty(const char *name) { return osCPP.DescribeProperty(name); } - int SCI_METHOD PropertySet(const char *key, const char *val); + Sci_Position SCI_METHOD PropertySet(const char *key, const char *val); const char * SCI_METHOD DescribeWordListSets() { return osCPP.DescribeWordListSets(); } - int SCI_METHOD WordListSet(int n, const char *wl); - void SCI_METHOD Lex(unsigned int startPos, int length, int initStyle, IDocument *pAccess); - void SCI_METHOD Fold(unsigned int startPos, int length, int initStyle, IDocument *pAccess); + Sci_Position SCI_METHOD WordListSet(int n, const char *wl); + void SCI_METHOD Lex(Sci_PositionU startPos, Sci_Position length, int initStyle, IDocument *pAccess); + void SCI_METHOD Fold(Sci_PositionU startPos, Sci_Position length, int initStyle, IDocument *pAccess); void * SCI_METHOD PrivateCall(int, void *) { return 0; @@ -555,7 +555,7 @@ public: bool EvaluateExpression(const std::string &expr, const SymbolTable &preprocessorDefinitions); }; -int SCI_METHOD LexerCPP::PropertySet(const char *key, const char *val) { +Sci_Position SCI_METHOD LexerCPP::PropertySet(const char *key, const char *val) { if (osCPP.PropertySet(&options, key, val)) { if (strcmp(key, "lexer.cpp.allow.dollars") == 0) { setWord = CharacterSet(CharacterSet::setAlphaNum, "._", 0x80, true); @@ -568,7 +568,7 @@ int SCI_METHOD LexerCPP::PropertySet(const char *key, const char *val) { return -1; } -int SCI_METHOD LexerCPP::WordListSet(int n, const char *wl) { +Sci_Position SCI_METHOD LexerCPP::WordListSet(int n, const char *wl) { WordList *wordListN = 0; switch (n) { case 0: @@ -590,7 +590,7 @@ int SCI_METHOD LexerCPP::WordListSet(int n, const char *wl) { wordListN = &markerList; break; } - int firstModification = -1; + Sci_Position firstModification = -1; if (wordListN) { WordList wlNew; wlNew.Set(wl); @@ -630,14 +630,14 @@ int SCI_METHOD LexerCPP::WordListSet(int n, const char *wl) { // Functor used to truncate history struct After { - int line; - explicit After(int line_) : line(line_) {} + Sci_Position line; + explicit After(Sci_Position line_) : line(line_) {} bool operator()(PPDefinition &p) const { return p.line > line; } }; -void SCI_METHOD LexerCPP::Lex(unsigned int startPos, int length, int initStyle, IDocument *pAccess) { +void SCI_METHOD LexerCPP::Lex(Sci_PositionU startPos, Sci_Position length, int initStyle, IDocument *pAccess) { LexAccessor styler(pAccess); CharacterSet setOKBeforeRE(CharacterSet::setNone, "([{=,:;!%^&*|?~+-"); @@ -664,13 +664,13 @@ void SCI_METHOD LexerCPP::Lex(unsigned int startPos, int length, int initStyle, bool inRERange = false; bool seenDocKeyBrace = false; - int lineCurrent = styler.GetLine(startPos); + Sci_Position lineCurrent = styler.GetLine(startPos); if ((MaskActive(initStyle) == SCE_C_PREPROCESSOR) || (MaskActive(initStyle) == SCE_C_COMMENTLINE) || (MaskActive(initStyle) == SCE_C_COMMENTLINEDOC)) { // Set continuationLine if last character of previous line is '\' if (lineCurrent > 0) { - int endLinePrevious = styler.LineEnd(lineCurrent - 1); + Sci_Position endLinePrevious = styler.LineEnd(lineCurrent - 1); if (endLinePrevious > 0) { continuationLine = styler.SafeGetCharAt(endLinePrevious-1) == '\\'; } @@ -679,7 +679,7 @@ void SCI_METHOD LexerCPP::Lex(unsigned int startPos, int length, int initStyle, // look back to set chPrevNonWhite properly for better regex colouring if (startPos > 0) { - int back = startPos; + Sci_Position back = startPos; while (--back && IsSpaceEquiv(MaskActive(styler.StyleAt(back)))) ; if (MaskActive(styler.StyleAt(back)) == SCE_C_OPERATOR) { @@ -719,7 +719,7 @@ void SCI_METHOD LexerCPP::Lex(unsigned int startPos, int length, int initStyle, const WordClassifier &classifierIdentifiers = subStyles.Classifier(SCE_C_IDENTIFIER); const WordClassifier &classifierDocKeyWords = subStyles.Classifier(SCE_C_COMMENTDOCKEYWORD); - int lineEndNext = styler.LineEnd(lineCurrent); + Sci_Position lineEndNext = styler.LineEnd(lineCurrent); for (; sc.More();) { @@ -757,7 +757,7 @@ void SCI_METHOD LexerCPP::Lex(unsigned int startPos, int length, int initStyle, // Handle line continuation generically. if (sc.ch == '\\') { - if (static_cast((sc.currentPos+1)) >= lineEndNext) { + if (static_cast((sc.currentPos+1)) >= lineEndNext) { lineCurrent++; lineEndNext = styler.LineEnd(lineCurrent); vlls.Add(lineCurrent, preproc); @@ -1026,7 +1026,7 @@ void SCI_METHOD LexerCPP::Lex(unsigned int startPos, int length, int initStyle, while ((sc.ch < 0x80) && islower(sc.ch)) sc.Forward(); // gobble regex flags sc.SetState(SCE_C_DEFAULT|activitySet); - } else if (sc.ch == '\\' && (static_cast(sc.currentPos+1) < lineEndNext)) { + } else if (sc.ch == '\\' && (static_cast(sc.currentPos+1) < lineEndNext)) { // Gobble up the escaped character sc.Forward(); } else if (sc.ch == '[') { @@ -1092,7 +1092,6 @@ void SCI_METHOD LexerCPP::Lex(unsigned int startPos, int length, int initStyle, } else if (options.backQuotedStrings && sc.Match('`')) { sc.SetState(SCE_C_STRINGRAW|activitySet); rawStringTerminator = "`"; - sc.Forward(); } else if (IsADigit(sc.ch) || (sc.ch == '.' && IsADigit(sc.chNext))) { if (lastWordWasUUID) { sc.SetState(SCE_C_UUID|activitySet); @@ -1133,7 +1132,7 @@ void SCI_METHOD LexerCPP::Lex(unsigned int startPos, int length, int initStyle, if (MaskActive(styler.StyleAt(sc.currentPos - 1)) == SCE_C_STRINGRAW) { sc.SetState(SCE_C_STRINGRAW|activitySet); rawStringTerminator = ")"; - for (int termPos = sc.currentPos + 1;; termPos++) { + for (Sci_Position termPos = sc.currentPos + 1;; termPos++) { char chTerminator = styler.SafeGetCharAt(termPos, '('); if (chTerminator == '(') break; @@ -1246,11 +1245,10 @@ void SCI_METHOD LexerCPP::Lex(unsigned int startPos, int length, int initStyle, } } else if (sc.Match("undef")) { if (options.updatePreprocessor && !preproc.IsInactive()) { - std::string restOfLine = GetRestOfLine(styler, sc.currentPos + 5, true); + const std::string restOfLine = GetRestOfLine(styler, sc.currentPos + 5, false); std::vector tokens = Tokenize(restOfLine); - std::string key; if (tokens.size() >= 1) { - key = tokens[0]; + const std::string key = tokens[0]; preprocessorDefinitions.erase(key); ppDefineHistory.push_back(PPDefinition(lineCurrent, key, "", true)); definitionsChanged = true; @@ -1281,28 +1279,28 @@ void SCI_METHOD LexerCPP::Lex(unsigned int startPos, int length, int initStyle, // level store to make it easy to pick up with each increment // and to make it possible to fiddle the current level for "} else {". -void SCI_METHOD LexerCPP::Fold(unsigned int startPos, int length, int initStyle, IDocument *pAccess) { +void SCI_METHOD LexerCPP::Fold(Sci_PositionU startPos, Sci_Position length, int initStyle, IDocument *pAccess) { if (!options.fold) return; LexAccessor styler(pAccess); - unsigned int endPos = startPos + length; + Sci_PositionU endPos = startPos + length; int visibleChars = 0; bool inLineComment = false; - int lineCurrent = styler.GetLine(startPos); + Sci_Position lineCurrent = styler.GetLine(startPos); int levelCurrent = SC_FOLDLEVELBASE; if (lineCurrent > 0) levelCurrent = styler.LevelAt(lineCurrent-1) >> 16; - unsigned int lineStartNext = styler.LineStart(lineCurrent+1); + Sci_PositionU lineStartNext = styler.LineStart(lineCurrent+1); int levelMinCurrent = levelCurrent; int levelNext = levelCurrent; char chNext = styler[startPos]; int styleNext = MaskActive(styler.StyleAt(startPos)); int style = MaskActive(initStyle); const bool userDefinedFoldMarkers = !options.foldExplicitStart.empty() && !options.foldExplicitEnd.empty(); - for (unsigned int i = startPos; i < endPos; i++) { + for (Sci_PositionU i = startPos; i < endPos; i++) { char ch = chNext; chNext = styler.SafeGetCharAt(i + 1); int stylePrev = style; @@ -1339,7 +1337,7 @@ void SCI_METHOD LexerCPP::Fold(unsigned int startPos, int length, int initStyle, } if (options.foldPreprocessor && (style == SCE_C_PREPROCESSOR)) { if (ch == '#') { - unsigned int j = i + 1; + Sci_PositionU j = i + 1; while ((j < endPos) && IsASpaceOrTab(styler.SafeGetCharAt(j))) { j++; } @@ -1381,7 +1379,7 @@ void SCI_METHOD LexerCPP::Fold(unsigned int startPos, int length, int initStyle, lineStartNext = styler.LineStart(lineCurrent+1); levelCurrent = levelNext; levelMinCurrent = levelCurrent; - if (atEOL && (i == static_cast(styler.Length()-1))) { + if (atEOL && (i == static_cast(styler.Length()-1))) { // There is an empty line at end of file so give it same level and empty styler.SetLevel(lineCurrent, (levelCurrent | levelCurrent << 16) | SC_FOLDLEVELWHITEFLAG); } @@ -1469,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()); @@ -1483,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/src/stc/scintilla/lexers/LexCSS.cxx b/src/stc/scintilla/lexers/LexCSS.cxx index 036bb2e0ab..19345af547 100644 --- a/src/stc/scintilla/lexers/LexCSS.cxx +++ b/src/stc/scintilla/lexers/LexCSS.cxx @@ -58,11 +58,11 @@ inline bool IsCssOperator(const int ch) { } // look behind (from start of document to our start position) to determine current nesting level -inline int NestingLevelLookBehind(unsigned int startPos, Accessor &styler) { +inline int NestingLevelLookBehind(Sci_PositionU startPos, Accessor &styler) { int ch; int nestingLevel = 0; - for (unsigned int i = 0; i < startPos; i++) { + for (Sci_PositionU i = 0; i < startPos; i++) { ch = styler.SafeGetCharAt(i); if (ch == '{') nestingLevel++; @@ -73,7 +73,7 @@ inline int NestingLevelLookBehind(unsigned int startPos, Accessor &styler) { return nestingLevel; } -static void ColouriseCssDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[], Accessor &styler) { +static void ColouriseCssDoc(Sci_PositionU startPos, Sci_Position length, int initStyle, WordList *keywordlists[], Accessor &styler) { WordList &css1Props = *keywordlists[0]; WordList &pseudoClasses = *keywordlists[1]; WordList &css2Props = *keywordlists[2]; @@ -131,7 +131,7 @@ static void ColouriseCssDoc(unsigned int startPos, int length, int initStyle, Wo if (lastStateC == -1) { // backtrack to get last state: // comments are like whitespace, so we must return to the previous state - unsigned int i = startPos; + Sci_PositionU i = startPos; for (; i > 0; i--) { if ((lastStateC = styler.StyleAt(i-1)) != SCE_CSS_COMMENT) { if (lastStateC == SCE_CSS_OPERATOR) { @@ -165,7 +165,7 @@ static void ColouriseCssDoc(unsigned int startPos, int length, int initStyle, Wo if (sc.state == SCE_CSS_DOUBLESTRING || sc.state == SCE_CSS_SINGLESTRING) { if (sc.ch != (sc.state == SCE_CSS_DOUBLESTRING ? '\"' : '\'')) continue; - unsigned int i = sc.currentPos; + Sci_PositionU i = sc.currentPos; while (i && styler[i-1] == '\\') i--; if ((sc.currentPos - i) % 2 == 1) @@ -175,7 +175,7 @@ static void ColouriseCssDoc(unsigned int startPos, int length, int initStyle, Wo if (sc.state == SCE_CSS_OPERATOR) { if (op == ' ') { - unsigned int i = startPos; + Sci_PositionU i = startPos; op = styler.SafeGetCharAt(i-1); opPrev = styler.SafeGetCharAt(i-2); while (--i) { @@ -380,10 +380,10 @@ static void ColouriseCssDoc(unsigned int startPos, int length, int initStyle, Wo // check for nested rule selector if (sc.state == SCE_CSS_IDENTIFIER && (IsAWordChar(sc.ch) || sc.ch == ':' || sc.ch == '.' || sc.ch == '#')) { // look ahead to see whether { comes before next ; and } - unsigned int endPos = startPos + length; + Sci_PositionU endPos = startPos + length; int ch; - for (unsigned int i = sc.currentPos; i < endPos; i++) { + for (Sci_PositionU i = sc.currentPos; i < endPos; i++) { ch = styler.SafeGetCharAt(i); if (ch == ';' || ch == '}') break; @@ -502,17 +502,17 @@ static void ColouriseCssDoc(unsigned int startPos, int length, int initStyle, Wo sc.Complete(); } -static void FoldCSSDoc(unsigned int startPos, int length, int, WordList *[], Accessor &styler) { +static void FoldCSSDoc(Sci_PositionU startPos, Sci_Position length, int, WordList *[], Accessor &styler) { bool foldComment = styler.GetPropertyInt("fold.comment") != 0; bool foldCompact = styler.GetPropertyInt("fold.compact", 1) != 0; - unsigned int endPos = startPos + length; + Sci_PositionU endPos = startPos + length; int visibleChars = 0; - int lineCurrent = styler.GetLine(startPos); + Sci_Position lineCurrent = styler.GetLine(startPos); int levelPrev = styler.LevelAt(lineCurrent) & SC_FOLDLEVELNUMBERMASK; int levelCurrent = levelPrev; char chNext = styler[startPos]; bool inComment = (styler.StyleAt(startPos-1) == SCE_CSS_COMMENT); - for (unsigned int i = startPos; i < endPos; i++) { + for (Sci_PositionU i = startPos; i < endPos; i++) { char ch = chNext; chNext = styler.SafeGetCharAt(i + 1); int style = styler.StyleAt(i); diff --git a/src/stc/scintilla/lexers/LexCaml.cxx b/src/stc/scintilla/lexers/LexCaml.cxx index f576e3e234..df87815419 100644 --- a/src/stc/scintilla/lexers/LexCaml.cxx +++ b/src/stc/scintilla/lexers/LexCaml.cxx @@ -66,18 +66,18 @@ using namespace Scintilla; #endif static void ColouriseCamlDoc( - unsigned int startPos, int length, + Sci_PositionU startPos, Sci_Position length, int initStyle, WordList *keywordlists[], Accessor &styler); static void FoldCamlDoc( - unsigned int startPos, int length, + Sci_PositionU startPos, Sci_Position length, int initStyle, WordList *keywordlists[], Accessor &styler); -static void InternalLexOrFold(int lexOrFold, unsigned int startPos, int length, +static void InternalLexOrFold(int lexOrFold, Sci_PositionU startPos, Sci_Position length, int initStyle, char *words[], WindowID window, char *props); static const char* LexerName = "caml"; @@ -109,7 +109,7 @@ long Platform::SendScintillaPointer(WindowID w, unsigned int msg, unsigned long reinterpret_cast(lParam)); } -void EXT_LEXER_DECL Fold(unsigned int lexer, unsigned int startPos, int length, +void EXT_LEXER_DECL Fold(unsigned int lexer, Sci_PositionU startPos, Sci_Position length, int initStyle, char *words[], WindowID window, char *props) { // below useless evaluation(s) to supress "not used" warnings @@ -138,7 +138,7 @@ void EXT_LEXER_DECL GetLexerName(unsigned int Index, char *name, int buflength) } } -void EXT_LEXER_DECL Lex(unsigned int lexer, unsigned int startPos, int length, +void EXT_LEXER_DECL Lex(unsigned int lexer, Sci_PositionU startPos, Sci_Position length, int initStyle, char *words[], WindowID window, char *props) { // below useless evaluation(s) to supress "not used" warnings @@ -147,7 +147,7 @@ void EXT_LEXER_DECL Lex(unsigned int lexer, unsigned int startPos, int length, InternalLexOrFold(0, startPos, length, initStyle, words, window, props); } -static void InternalLexOrFold(int foldOrLex, unsigned int startPos, int length, +static void InternalLexOrFold(int foldOrLex, Sci_PositionU startPos, Sci_Position length, int initStyle, char *words[], WindowID window, char *props) { // create and initialize a WindowAccessor (including contained PropSet) @@ -180,7 +180,7 @@ static #endif /* BUILD_AS_EXTERNAL_LEXER */ void ColouriseCamlDoc( - unsigned int startPos, int length, + Sci_PositionU startPos, Sci_Position length, int initStyle, WordList *keywordlists[], Accessor &styler) @@ -188,7 +188,8 @@ void ColouriseCamlDoc( // initialize styler StyleContext sc(startPos, length, initStyle, styler); - int chBase = 0, chToken = 0, chLit = 0; + Sci_PositionU chToken = 0; + int chBase = 0, chLit = 0; WordList& keywords = *keywordlists[0]; WordList& keywords2 = *keywordlists[1]; WordList& keywords3 = *keywordlists[2]; @@ -206,7 +207,7 @@ void ColouriseCamlDoc( while (sc.More()) { // set up [per-char] state info int state2 = -1; // (ASSUME no state change) - int chColor = sc.currentPos - 1;// (ASSUME standard coloring range) + Sci_Position chColor = sc.currentPos - 1;// (ASSUME standard coloring range) bool advance = true; // (ASSUME scanner "eats" 1 char) // step state machine @@ -254,11 +255,11 @@ void ColouriseCamlDoc( case SCE_CAML_IDENTIFIER: // [try to] interpret as [additional] identifier char if (!(iscaml(sc.ch) || sc.Match('\''))) { - const int n = sc.currentPos - chToken; + const Sci_Position n = sc.currentPos - chToken; if (n < 24) { // length is believable as keyword, [re-]construct token char t[24]; - for (int i = -n; i < 0; i++) + for (Sci_Position i = -n; i < 0; i++) t[n + i] = static_cast(sc.GetRelative(i)); t[n] = '\0'; // special-case "_" token as KEYWORD @@ -390,7 +391,7 @@ void ColouriseCamlDoc( state2 = SCE_CAML_STRING, sc.ch = ' ' /* (...\") */, chColor++, styler.ColourTo(chColor, SCE_CAML_WHITE), styler.Flush(); // ... then backtrack to determine original SML literal type - int p = chColor - 2; + Sci_Position p = chColor - 2; for (; p >= 0 && styler.StyleAt(p) == SCE_CAML_WHITE; p--) ; if (p >= 0) state2 = static_cast(styler.StyleAt(p)); @@ -437,7 +438,7 @@ void ColouriseCamlDoc( static #endif /* BUILD_AS_EXTERNAL_LEXER */ void FoldCamlDoc( - unsigned int, int, + Sci_PositionU, Sci_Position, int, WordList *[], Accessor &) diff --git a/src/stc/scintilla/lexers/LexCmake.cxx b/src/stc/scintilla/lexers/LexCmake.cxx index fb79abf264..1cbca36113 100644 --- a/src/stc/scintilla/lexers/LexCmake.cxx +++ b/src/stc/scintilla/lexers/LexCmake.cxx @@ -43,10 +43,10 @@ static bool isCmakeLetter(char ch) return(ch >= 'A' && ch <= 'Z') || (ch >= 'a' && ch <= 'z'); } -static bool CmakeNextLineHasElse(unsigned int start, unsigned int end, Accessor &styler) +static bool CmakeNextLineHasElse(Sci_PositionU start, Sci_PositionU end, Accessor &styler) { - int nNextLine = -1; - for ( unsigned int i = start; i < end; i++ ) { + Sci_Position nNextLine = -1; + for ( Sci_PositionU i = start; i < end; i++ ) { char cNext = styler.SafeGetCharAt( i ); if ( cNext == '\n' ) { nNextLine = i+1; @@ -57,7 +57,7 @@ static bool CmakeNextLineHasElse(unsigned int start, unsigned int end, Accessor if ( nNextLine == -1 ) // We never foudn the next line... return false; - for ( unsigned int firstChar = nNextLine; firstChar < end; firstChar++ ) { + for ( Sci_PositionU firstChar = nNextLine; firstChar < end; firstChar++ ) { char cNext = styler.SafeGetCharAt( firstChar ); if ( cNext == ' ' ) continue; @@ -71,7 +71,7 @@ static bool CmakeNextLineHasElse(unsigned int start, unsigned int end, Accessor return false; } -static int calculateFoldCmake(unsigned int start, unsigned int end, int foldlevel, Accessor &styler, bool bElse) +static int calculateFoldCmake(Sci_PositionU start, Sci_PositionU end, int foldlevel, Accessor &styler, bool bElse) { // If the word is too long, it is not what we are looking for if ( end - start > 20 ) @@ -100,7 +100,7 @@ static int calculateFoldCmake(unsigned int start, unsigned int end, int foldleve return newFoldlevel; } -static int classifyWordCmake(unsigned int start, unsigned int end, WordList *keywordLists[], Accessor &styler ) +static int classifyWordCmake(Sci_PositionU start, Sci_PositionU end, WordList *keywordLists[], Accessor &styler ) { char word[100] = {0}; char lowercaseWord[100] = {0}; @@ -109,7 +109,7 @@ static int classifyWordCmake(unsigned int start, unsigned int end, WordList *key WordList &Parameters = *keywordLists[1]; WordList &UserDefined = *keywordLists[2]; - for (unsigned int i = 0; i < end - start + 1 && i < 99; i++) { + for (Sci_PositionU i = 0; i < end - start + 1 && i < 99; i++) { word[i] = static_cast( styler[ start + i ] ); lowercaseWord[i] = static_cast(tolower(word[i])); } @@ -162,7 +162,7 @@ static int classifyWordCmake(unsigned int start, unsigned int end, WordList *key return SCE_CMAKE_DEFAULT; } -static void ColouriseCmakeDoc(unsigned int startPos, int length, int, WordList *keywordLists[], Accessor &styler) +static void ColouriseCmakeDoc(Sci_PositionU startPos, Sci_Position length, int, WordList *keywordLists[], Accessor &styler) { int state = SCE_CMAKE_DEFAULT; if ( startPos > 0 ) @@ -171,14 +171,14 @@ static void ColouriseCmakeDoc(unsigned int startPos, int length, int, WordList * styler.StartAt( startPos ); styler.GetLine( startPos ); - unsigned int nLengthDoc = startPos + length; + Sci_PositionU nLengthDoc = startPos + length; styler.StartSegment( startPos ); char cCurrChar; bool bVarInString = false; bool bClassicVarInString = false; - unsigned int i; + Sci_PositionU i; for ( i = startPos; i < nLengthDoc; i++ ) { cCurrChar = styler.SafeGetCharAt( i ); char cNextChar = styler.SafeGetCharAt(i+1); @@ -263,8 +263,8 @@ static void ColouriseCmakeDoc(unsigned int startPos, int length, int, WordList * } if ( cNextChar == '\r' || cNextChar == '\n' ) { - int nCurLine = styler.GetLine(i+1); - int nBack = i; + Sci_Position nCurLine = styler.GetLine(i+1); + Sci_Position nBack = i; // We need to check if the previous line has a \ in it... bool bNextLine = false; @@ -377,7 +377,7 @@ static void ColouriseCmakeDoc(unsigned int startPos, int length, int, WordList * styler.ColourTo(nLengthDoc-1,state); } -static void FoldCmakeDoc(unsigned int startPos, int length, int, WordList *[], Accessor &styler) +static void FoldCmakeDoc(Sci_PositionU startPos, Sci_Position length, int, WordList *[], Accessor &styler) { // No folding enabled, no reason to continue... if ( styler.GetPropertyInt("fold") == 0 ) @@ -385,18 +385,18 @@ static void FoldCmakeDoc(unsigned int startPos, int length, int, WordList *[], A bool foldAtElse = styler.GetPropertyInt("fold.at.else", 0) == 1; - int lineCurrent = styler.GetLine(startPos); - unsigned int safeStartPos = styler.LineStart( lineCurrent ); + Sci_Position lineCurrent = styler.GetLine(startPos); + Sci_PositionU safeStartPos = styler.LineStart( lineCurrent ); bool bArg1 = true; - int nWordStart = -1; + Sci_Position nWordStart = -1; int levelCurrent = SC_FOLDLEVELBASE; if (lineCurrent > 0) levelCurrent = styler.LevelAt(lineCurrent-1) >> 16; int levelNext = levelCurrent; - for (unsigned int i = safeStartPos; i < startPos + length; i++) { + for (Sci_PositionU i = safeStartPos; i < startPos + length; i++) { char chCurr = styler.SafeGetCharAt(i); if ( bArg1 ) { diff --git a/src/stc/scintilla/lexers/LexCoffeeScript.cxx b/src/stc/scintilla/lexers/LexCoffeeScript.cxx index 1667683218..f325600163 100644 --- a/src/stc/scintilla/lexers/LexCoffeeScript.cxx +++ b/src/stc/scintilla/lexers/LexCoffeeScript.cxx @@ -48,7 +48,7 @@ static bool IsSpaceEquiv(int state) { // Putting a space between the '++' post-inc operator and the '+' binary op // fixes this, and is highly recommended for readability anyway. static bool FollowsPostfixOperator(StyleContext &sc, Accessor &styler) { - int pos = (int) sc.currentPos; + Sci_Position pos = (Sci_Position) sc.currentPos; while (--pos > 0) { char ch = styler[pos]; if (ch == '+' || ch == '-') { @@ -58,29 +58,21 @@ static bool FollowsPostfixOperator(StyleContext &sc, Accessor &styler) { return false; } -static bool followsReturnKeyword(StyleContext &sc, Accessor &styler) { - // Don't look at styles, so no need to flush. - int pos = (int) sc.currentPos; - int currentLine = styler.GetLine(pos); - int lineStartPos = styler.LineStart(currentLine); +static bool followsKeyword(StyleContext &sc, Accessor &styler) { + Sci_Position pos = (Sci_Position) sc.currentPos; + Sci_Position currentLine = styler.GetLine(pos); + Sci_Position lineStartPos = styler.LineStart(currentLine); while (--pos > lineStartPos) { char ch = styler.SafeGetCharAt(pos); if (ch != ' ' && ch != '\t') { break; } } - const char *retBack = "nruter"; - const char *s = retBack; - while (*s - && pos >= lineStartPos - && styler.SafeGetCharAt(pos) == *s) { - s++; - pos--; - } - return !*s; + styler.Flush(); + return styler.StyleAt(pos) == SCE_COFFEESCRIPT_WORD; } -static void ColouriseCoffeeScriptDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[], +static void ColouriseCoffeeScriptDoc(Sci_PositionU startPos, Sci_Position length, int initStyle, WordList *keywordlists[], Accessor &styler) { WordList &keywords = *keywordlists[0]; @@ -97,9 +89,9 @@ static void ColouriseCoffeeScriptDoc(unsigned int startPos, int length, int init int visibleChars = 0; // look back to set chPrevNonWhite properly for better regex colouring - int endPos = startPos + length; + Sci_Position endPos = startPos + length; if (startPos > 0 && IsSpaceEquiv(initStyle)) { - unsigned int back = startPos; + Sci_PositionU back = startPos; styler.Flush(); while (back > 0 && IsSpaceEquiv(styler.StyleAt(--back))) ; @@ -146,6 +138,8 @@ static void ColouriseCoffeeScriptDoc(unsigned int startPos, int length, int init sc.ChangeState(SCE_COFFEESCRIPT_WORD2); } else if (keywords4.InList(s)) { sc.ChangeState(SCE_COFFEESCRIPT_GLOBALCLASS); + } else if (sc.LengthCurrent() > 0 && s[0] == '@') { + sc.ChangeState(SCE_COFFEESCRIPT_INSTANCEPROPERTY); } sc.SetState(SCE_COFFEESCRIPT_DEFAULT); } @@ -153,6 +147,7 @@ static void ColouriseCoffeeScriptDoc(unsigned int startPos, int length, int init case SCE_COFFEESCRIPT_WORD: case SCE_COFFEESCRIPT_WORD2: case SCE_COFFEESCRIPT_GLOBALCLASS: + case SCE_COFFEESCRIPT_INSTANCEPROPERTY: if (!setWord.Contains(sc.ch)) { sc.SetState(SCE_COFFEESCRIPT_DEFAULT); } @@ -239,7 +234,7 @@ static void ColouriseCoffeeScriptDoc(unsigned int startPos, int length, int init sc.Forward(); } else if (sc.ch == '/' && (setOKBeforeRE.Contains(chPrevNonWhite) - || followsReturnKeyword(sc, styler)) + || followsKeyword(sc, styler)) && (!setCouldBePostOp.Contains(chPrevNonWhite) || !FollowsPostfixOperator(sc, styler))) { sc.SetState(SCE_COFFEESCRIPT_REGEX); // JavaScript's RegEx @@ -257,6 +252,10 @@ static void ColouriseCoffeeScriptDoc(unsigned int startPos, int length, int init } } 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()) ; + } } } @@ -268,10 +267,10 @@ static void ColouriseCoffeeScriptDoc(unsigned int startPos, int length, int init sc.Complete(); } -static bool IsCommentLine(int line, Accessor &styler) { - int pos = styler.LineStart(line); - int eol_pos = styler.LineStart(line + 1) - 1; - for (int i = pos; i < eol_pos; i++) { +static bool IsCommentLine(Sci_Position line, Accessor &styler) { + Sci_Position pos = styler.LineStart(line); + Sci_Position eol_pos = styler.LineStart(line + 1) - 1; + for (Sci_Position i = pos; i < eol_pos; i++) { char ch = styler[i]; if (ch == '#') return true; @@ -281,12 +280,12 @@ static bool IsCommentLine(int line, Accessor &styler) { return false; } -static void FoldCoffeeScriptDoc(unsigned int startPos, int length, int, +static void FoldCoffeeScriptDoc(Sci_PositionU startPos, Sci_Position length, int, WordList *[], Accessor &styler) { // A simplified version of FoldPyDoc - const int maxPos = startPos + length; - const int maxLines = styler.GetLine(maxPos - 1); // Requested last line - const int docLines = styler.GetLine(styler.Length() - 1); // Available last line + const Sci_Position maxPos = startPos + length; + const Sci_Position maxLines = styler.GetLine(maxPos - 1); // Requested last line + const Sci_Position docLines = styler.GetLine(styler.Length() - 1); // Available last line // property fold.coffeescript.comment const bool foldComment = styler.GetPropertyInt("fold.coffeescript.comment") != 0; @@ -298,7 +297,7 @@ static void FoldCoffeeScriptDoc(unsigned int startPos, int length, int, // and so we can fix any preceding fold level (which is why we go back // at least one line in all cases) int spaceFlags = 0; - int lineCurrent = styler.GetLine(startPos); + Sci_Position lineCurrent = styler.GetLine(startPos); int indentCurrent = styler.IndentAmount(lineCurrent, &spaceFlags, NULL); while (lineCurrent > 0) { lineCurrent--; @@ -321,7 +320,7 @@ static void FoldCoffeeScriptDoc(unsigned int startPos, int length, int, // Gather info int lev = indentCurrent; - int lineNext = lineCurrent + 1; + Sci_Position lineNext = lineCurrent + 1; int indentNext = indentCurrent; if (lineNext <= docLines) { // Information about next line is only available if not at end of document @@ -365,7 +364,7 @@ static void FoldCoffeeScriptDoc(unsigned int startPos, int length, int, // which is indented more than the line after the end of // the comment-block, use the level of the block before - int skipLine = lineNext; + Sci_Position skipLine = lineNext; int skipLevel = levelAfterComments; while (--skipLine > lineCurrent) { diff --git a/src/stc/scintilla/lexers/LexConf.cxx b/src/stc/scintilla/lexers/LexConf.cxx index 6a1c8c018b..2eed51b714 100644 --- a/src/stc/scintilla/lexers/LexConf.cxx +++ b/src/stc/scintilla/lexers/LexConf.cxx @@ -31,14 +31,14 @@ using namespace Scintilla; #endif -static void ColouriseConfDoc(unsigned int startPos, int length, int, WordList *keywordLists[], Accessor &styler) +static void ColouriseConfDoc(Sci_PositionU startPos, Sci_Position length, int, WordList *keywordLists[], Accessor &styler) { int state = SCE_CONF_DEFAULT; char chNext = styler[startPos]; - int lengthDoc = startPos + length; + Sci_Position lengthDoc = startPos + length; // create a buffer large enough to take the largest chunk... char *buffer = new char[length+1]; - int bufferCount = 0; + Sci_Position bufferCount = 0; // this assumes that we have 2 keyword list in conf.properties WordList &directives = *keywordLists[0]; @@ -48,7 +48,7 @@ static void ColouriseConfDoc(unsigned int startPos, int length, int, WordList *k // using the hand-written state machine shown below styler.StartAt(startPos); styler.StartSegment(startPos); - for (int i = startPos; i < lengthDoc; i++) { + for (Sci_Position i = startPos; i < lengthDoc; i++) { char ch = chNext; chNext = styler.SafeGetCharAt(i + 1); diff --git a/src/stc/scintilla/lexers/LexCrontab.cxx b/src/stc/scintilla/lexers/LexCrontab.cxx index ad6668fa7b..b500d2d282 100644 --- a/src/stc/scintilla/lexers/LexCrontab.cxx +++ b/src/stc/scintilla/lexers/LexCrontab.cxx @@ -29,15 +29,15 @@ using namespace Scintilla; #endif -static void ColouriseNncrontabDoc(unsigned int startPos, int length, int, WordList +static void ColouriseNncrontabDoc(Sci_PositionU startPos, Sci_Position length, int, WordList *keywordLists[], Accessor &styler) { int state = SCE_NNCRONTAB_DEFAULT; char chNext = styler[startPos]; - int lengthDoc = startPos + length; + Sci_Position lengthDoc = startPos + length; // create a buffer large enough to take the largest chunk... char *buffer = new char[length+1]; - int bufferCount = 0; + Sci_Position bufferCount = 0; // used when highliting environment variables inside quoted string: bool insideString = false; @@ -50,7 +50,7 @@ static void ColouriseNncrontabDoc(unsigned int startPos, int length, int, WordLi // using the hand-written state machine shown below styler.StartAt(startPos); styler.StartSegment(startPos); - for (int i = startPos; i < lengthDoc; i++) { + for (Sci_Position i = startPos; i < lengthDoc; i++) { char ch = chNext; chNext = styler.SafeGetCharAt(i + 1); diff --git a/src/stc/scintilla/lexers/LexCsound.cxx b/src/stc/scintilla/lexers/LexCsound.cxx index da5bfeb8c6..6d065c8d1d 100644 --- a/src/stc/scintilla/lexers/LexCsound.cxx +++ b/src/stc/scintilla/lexers/LexCsound.cxx @@ -51,7 +51,7 @@ static inline bool IsCsoundOperator(char ch) { return false; } -static void ColouriseCsoundDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[], +static void ColouriseCsoundDoc(Sci_PositionU startPos, Sci_Position length, int initStyle, WordList *keywordlists[], Accessor &styler) { WordList &opcode = *keywordlists[0]; @@ -150,17 +150,17 @@ static void ColouriseCsoundDoc(unsigned int startPos, int length, int initStyle, sc.Complete(); } -static void FoldCsoundInstruments(unsigned int startPos, int length, int /* initStyle */, WordList *[], +static void FoldCsoundInstruments(Sci_PositionU startPos, Sci_Position length, int /* initStyle */, WordList *[], Accessor &styler) { - unsigned int lengthDoc = startPos + length; + Sci_PositionU lengthDoc = startPos + length; int visibleChars = 0; - int lineCurrent = styler.GetLine(startPos); + Sci_Position lineCurrent = styler.GetLine(startPos); int levelPrev = styler.LevelAt(lineCurrent) & SC_FOLDLEVELNUMBERMASK; int levelCurrent = levelPrev; char chNext = styler[startPos]; int stylePrev = 0; int styleNext = styler.StyleAt(startPos); - for (unsigned int i = startPos; i < lengthDoc; i++) { + for (Sci_PositionU i = startPos; i < lengthDoc; i++) { char ch = chNext; chNext = styler.SafeGetCharAt(i + 1); int style = styleNext; diff --git a/src/stc/scintilla/lexers/LexD.cxx b/src/stc/scintilla/lexers/LexD.cxx index 045c4cb73e..7c0177e99d 100644 --- a/src/stc/scintilla/lexers/LexD.cxx +++ b/src/stc/scintilla/lexers/LexD.cxx @@ -177,13 +177,13 @@ public: const char * SCI_METHOD DescribeProperty(const char *name) { return osD.DescribeProperty(name); } - int SCI_METHOD PropertySet(const char *key, const char *val); + Sci_Position SCI_METHOD PropertySet(const char *key, const char *val); const char * SCI_METHOD DescribeWordListSets() { return osD.DescribeWordListSets(); } - int SCI_METHOD WordListSet(int n, const char *wl); - void SCI_METHOD Lex(unsigned int startPos, int length, int initStyle, IDocument *pAccess); - void SCI_METHOD Fold(unsigned int startPos, int length, int initStyle, IDocument *pAccess); + Sci_Position SCI_METHOD WordListSet(int n, const char *wl); + void SCI_METHOD Lex(Sci_PositionU startPos, Sci_Position length, int initStyle, IDocument *pAccess); + void SCI_METHOD Fold(Sci_PositionU startPos, Sci_Position length, int initStyle, IDocument *pAccess); void * SCI_METHOD PrivateCall(int, void *) { return 0; @@ -197,14 +197,14 @@ public: } }; -int SCI_METHOD LexerD::PropertySet(const char *key, const char *val) { +Sci_Position SCI_METHOD LexerD::PropertySet(const char *key, const char *val) { if (osD.PropertySet(&options, key, val)) { return 0; } return -1; } -int SCI_METHOD LexerD::WordListSet(int n, const char *wl) { +Sci_Position SCI_METHOD LexerD::WordListSet(int n, const char *wl) { WordList *wordListN = 0; switch (n) { case 0: @@ -229,7 +229,7 @@ int SCI_METHOD LexerD::WordListSet(int n, const char *wl) { wordListN = &keywords7; break; } - int firstModification = -1; + Sci_Position firstModification = -1; if (wordListN) { WordList wlNew; wlNew.Set(wl); @@ -241,14 +241,14 @@ int SCI_METHOD LexerD::WordListSet(int n, const char *wl) { return firstModification; } -void SCI_METHOD LexerD::Lex(unsigned int startPos, int length, int initStyle, IDocument *pAccess) { +void SCI_METHOD LexerD::Lex(Sci_PositionU startPos, Sci_Position length, int initStyle, IDocument *pAccess) { LexAccessor styler(pAccess); int styleBeforeDCKeyword = SCE_D_DEFAULT; StyleContext sc(startPos, length, initStyle, styler); - int curLine = styler.GetLine(startPos); + Sci_Position curLine = styler.GetLine(startPos); int curNcLevel = curLine > 0? styler.GetLineState(curLine-1): 0; bool numFloat = false; // Float literals have '+' and '-' signs bool numHex = false; @@ -471,16 +471,16 @@ void SCI_METHOD LexerD::Lex(unsigned int startPos, int length, int initStyle, ID // level store to make it easy to pick up with each increment // and to make it possible to fiddle the current level for "} else {". -void SCI_METHOD LexerD::Fold(unsigned int startPos, int length, int initStyle, IDocument *pAccess) { +void SCI_METHOD LexerD::Fold(Sci_PositionU startPos, Sci_Position length, int initStyle, IDocument *pAccess) { if (!options.fold) return; LexAccessor styler(pAccess); - unsigned int endPos = startPos + length; + Sci_PositionU endPos = startPos + length; int visibleChars = 0; - int lineCurrent = styler.GetLine(startPos); + Sci_Position lineCurrent = styler.GetLine(startPos); int levelCurrent = SC_FOLDLEVELBASE; if (lineCurrent > 0) levelCurrent = styler.LevelAt(lineCurrent-1) >> 16; @@ -491,7 +491,7 @@ void SCI_METHOD LexerD::Fold(unsigned int startPos, int length, int initStyle, I int style = initStyle; bool foldAtElse = options.foldAtElseInt >= 0 ? options.foldAtElseInt != 0 : options.foldAtElse; const bool userDefinedFoldMarkers = !options.foldExplicitStart.empty() && !options.foldExplicitEnd.empty(); - for (unsigned int i = startPos; i < endPos; i++) { + for (Sci_PositionU i = startPos; i < endPos; i++) { char ch = chNext; chNext = styler.SafeGetCharAt(i + 1); int stylePrev = style; diff --git a/src/stc/scintilla/lexers/LexDMAP.cxx b/src/stc/scintilla/lexers/LexDMAP.cxx index 431000a4e3..eb43cde6d3 100644 --- a/src/stc/scintilla/lexers/LexDMAP.cxx +++ b/src/stc/scintilla/lexers/LexDMAP.cxx @@ -38,14 +38,14 @@ static inline bool IsAWordStart(const int ch) { return (ch < 0x80) && (isalnum(ch)); } /***************************************/ -static void ColouriseDMAPDoc(unsigned int startPos, int length, int initStyle, +static void ColouriseDMAPDoc(Sci_PositionU startPos, Sci_Position length, int initStyle, WordList *keywordlists[], Accessor &styler) { WordList &keywords = *keywordlists[0]; WordList &keywords2 = *keywordlists[1]; WordList &keywords3 = *keywordlists[2]; /***************************************/ - int posLineStart = 0, numNonBlank = 0; - int endPos = startPos + length; + Sci_Position posLineStart = 0, numNonBlank = 0; + Sci_Position endPos = startPos + length; /***************************************/ // backtrack to the nearest keyword while ((startPos > 1) && (styler.StyleAt(startPos) != SCE_DMAP_WORD)) { @@ -65,7 +65,7 @@ static void ColouriseDMAPDoc(unsigned int startPos, int length, int initStyle, if (!IsASpaceOrTab(sc.ch)) numNonBlank ++; /***********************************************/ // Handle data appearing after column 72; it is ignored - int toLineStart = sc.currentPos - posLineStart; + Sci_Position toLineStart = sc.currentPos - posLineStart; if (toLineStart >= 72 || sc.ch == '$') { sc.SetState(SCE_DMAP_COMMENT); while (!sc.atLineEnd && sc.More()) sc.Forward(); // Until line end @@ -151,26 +151,26 @@ static int classifyFoldPointDMAP(const char* s, const char* prevWord) { return lev; } // Folding the code -static void FoldDMAPDoc(unsigned int startPos, int length, int initStyle, +static void FoldDMAPDoc(Sci_PositionU startPos, Sci_Position length, int initStyle, WordList *[], Accessor &styler) { // // bool foldComment = styler.GetPropertyInt("fold.comment") != 0; // Do not know how to fold the comment at the moment. // bool foldCompact = styler.GetPropertyInt("fold.compact", 1) != 0; - unsigned int endPos = startPos + length; + Sci_PositionU endPos = startPos + length; int visibleChars = 0; - int lineCurrent = styler.GetLine(startPos); + Sci_Position lineCurrent = styler.GetLine(startPos); int levelPrev = styler.LevelAt(lineCurrent) & SC_FOLDLEVELNUMBERMASK; int levelCurrent = levelPrev; char chNext = styler[startPos]; int styleNext = styler.StyleAt(startPos); int style = initStyle; /***************************************/ - int lastStart = 0; + Sci_Position lastStart = 0; char prevWord[32] = ""; /***************************************/ - for (unsigned int i = startPos; i < endPos; i++) { + for (Sci_PositionU i = startPos; i < endPos; i++) { char ch = chNext; chNext = styler.SafeGetCharAt(i + 1); int stylePrev = style; @@ -186,7 +186,7 @@ static void FoldDMAPDoc(unsigned int startPos, int length, int initStyle, if (style == SCE_DMAP_WORD) { if(iswordchar(ch) && !iswordchar(chNext)) { char s[32]; - unsigned int k; + Sci_PositionU k; for(k=0; (k<31 ) && (k(tolower(styler[lastStart+k])); } diff --git a/src/stc/scintilla/lexers/LexDMIS.cxx b/src/stc/scintilla/lexers/LexDMIS.cxx index a903e9da65..7eeecca0e5 100644 --- a/src/stc/scintilla/lexers/LexDMIS.cxx +++ b/src/stc/scintilla/lexers/LexDMIS.cxx @@ -76,11 +76,11 @@ class LexerDMIS : public ILexer return NULL; } - int SCI_METHOD PropertySet(const char *, const char *) { + Sci_Position SCI_METHOD PropertySet(const char *, const char *) { return -1; } - int SCI_METHOD WordListSet(int n, const char *wl); + Sci_Position SCI_METHOD WordListSet(int n, const char *wl); void * SCI_METHOD PrivateCall(int, void *) { return NULL; @@ -91,8 +91,8 @@ class LexerDMIS : public ILexer } const char * SCI_METHOD DescribeWordListSets(); - void SCI_METHOD Lex(unsigned int startPos, int lengthDoc, int initStyle, IDocument *pAccess); - void SCI_METHOD Fold(unsigned int startPos, int lengthDoc, int initStyle, IDocument *pAccess); + void SCI_METHOD Lex(Sci_PositionU startPos, Sci_Position lengthDoc, int initStyle, IDocument *pAccess); + void SCI_METHOD Fold(Sci_PositionU startPos, Sci_Position lengthDoc, int initStyle, IDocument *pAccess); }; @@ -145,7 +145,7 @@ LexerDMIS::~LexerDMIS(void) { delete[] this->m_wordListSets; } -int SCI_METHOD LexerDMIS::WordListSet(int n, const char *wl) +Sci_Position SCI_METHOD LexerDMIS::WordListSet(int n, const char *wl) { switch (n) { case 0: @@ -185,9 +185,9 @@ const char * SCI_METHOD LexerDMIS::DescribeWordListSets() return this->m_wordListSets; } -void SCI_METHOD LexerDMIS::Lex(unsigned int startPos, int lengthDoc, int initStyle, IDocument *pAccess) +void SCI_METHOD LexerDMIS::Lex(Sci_PositionU startPos, Sci_Position lengthDoc, int initStyle, IDocument *pAccess) { - const unsigned int MAX_STR_LEN = 100; + const Sci_PositionU MAX_STR_LEN = 100; LexAccessor styler(pAccess); StyleContext scCTX(startPos, lengthDoc, initStyle, styler); @@ -281,14 +281,14 @@ void SCI_METHOD LexerDMIS::Lex(unsigned int startPos, int lengthDoc, int initSty scCTX.Complete(); } -void SCI_METHOD LexerDMIS::Fold(unsigned int startPos, int lengthDoc, int, IDocument *pAccess) +void SCI_METHOD LexerDMIS::Fold(Sci_PositionU startPos, Sci_Position lengthDoc, int, IDocument *pAccess) { const int MAX_STR_LEN = 100; LexAccessor styler(pAccess); - unsigned int endPos = startPos + lengthDoc; + Sci_PositionU endPos = startPos + lengthDoc; char chNext = styler[startPos]; - int lineCurrent = styler.GetLine(startPos); + Sci_Position lineCurrent = styler.GetLine(startPos); int levelPrev = styler.LevelAt(lineCurrent) & SC_FOLDLEVELNUMBERMASK; int levelCurrent = levelPrev; int strPos = 0; @@ -300,7 +300,7 @@ void SCI_METHOD LexerDMIS::Fold(unsigned int startPos, int lengthDoc, int, IDocu tmpStr = new char[MAX_STR_LEN]; memset(tmpStr, 0, MAX_STR_LEN*sizeof(char)); - for (unsigned int i=startPos; i +// The License.txt file describes the conditions under which this software may be distributed. + +#include +#include +#include +#include +#include +#include + +#include "ILexer.h" +#include "Scintilla.h" +#include "SciLexer.h" + +#include "WordList.h" +#include "LexAccessor.h" +#include "Accessor.h" +#include "StyleContext.h" +#include "CharacterSet.h" +#include "LexerModule.h" + +#ifdef SCI_NAMESPACE +using namespace Scintilla; +#endif + +static inline bool AtEOL(Accessor &styler, Sci_PositionU i) { + return (styler[i] == '\n') || + ((styler[i] == '\r') && (styler.SafeGetCharAt(i + 1) != '\n')); +} + +#define DIFF_BUFFER_START_SIZE 16 +// Note that ColouriseDiffLine analyzes only the first DIFF_BUFFER_START_SIZE +// characters of each line to classify the line. + +static void ColouriseDiffLine(char *lineBuffer, Sci_Position endLine, Accessor &styler) { + // It is needed to remember the current state to recognize starting + // comment lines before the first "diff " or "--- ". If a real + // difference starts then each line starting with ' ' is a whitespace + // otherwise it is considered a comment (Only in..., Binary file...) + if (0 == strncmp(lineBuffer, "diff ", 5)) { + styler.ColourTo(endLine, SCE_DIFF_COMMAND); + } else if (0 == strncmp(lineBuffer, "Index: ", 7)) { // For subversion's diff + styler.ColourTo(endLine, SCE_DIFF_COMMAND); + } else if (0 == strncmp(lineBuffer, "---", 3) && lineBuffer[3] != '-') { + // In a context diff, --- appears in both the header and the position markers + if (lineBuffer[3] == ' ' && atoi(lineBuffer + 4) && !strchr(lineBuffer, '/')) + styler.ColourTo(endLine, SCE_DIFF_POSITION); + else if (lineBuffer[3] == '\r' || lineBuffer[3] == '\n') + styler.ColourTo(endLine, SCE_DIFF_POSITION); + else + styler.ColourTo(endLine, SCE_DIFF_HEADER); + } else if (0 == strncmp(lineBuffer, "+++ ", 4)) { + // I don't know of any diff where "+++ " is a position marker, but for + // consistency, do the same as with "--- " and "*** ". + if (atoi(lineBuffer+4) && !strchr(lineBuffer, '/')) + styler.ColourTo(endLine, SCE_DIFF_POSITION); + else + styler.ColourTo(endLine, SCE_DIFF_HEADER); + } else if (0 == strncmp(lineBuffer, "====", 4)) { // For p4's diff + styler.ColourTo(endLine, SCE_DIFF_HEADER); + } else if (0 == strncmp(lineBuffer, "***", 3)) { + // In a context diff, *** appears in both the header and the position markers. + // Also ******** is a chunk header, but here it's treated as part of the + // position marker since there is no separate style for a chunk header. + if (lineBuffer[3] == ' ' && atoi(lineBuffer+4) && !strchr(lineBuffer, '/')) + styler.ColourTo(endLine, SCE_DIFF_POSITION); + else if (lineBuffer[3] == '*') + styler.ColourTo(endLine, SCE_DIFF_POSITION); + else + styler.ColourTo(endLine, SCE_DIFF_HEADER); + } else if (0 == strncmp(lineBuffer, "? ", 2)) { // For difflib + styler.ColourTo(endLine, SCE_DIFF_HEADER); + } else if (lineBuffer[0] == '@') { + styler.ColourTo(endLine, SCE_DIFF_POSITION); + } else if (lineBuffer[0] >= '0' && lineBuffer[0] <= '9') { + styler.ColourTo(endLine, SCE_DIFF_POSITION); + } else if (lineBuffer[0] == '-' || lineBuffer[0] == '<') { + styler.ColourTo(endLine, SCE_DIFF_DELETED); + } else if (lineBuffer[0] == '+' || lineBuffer[0] == '>') { + styler.ColourTo(endLine, SCE_DIFF_ADDED); + } else if (lineBuffer[0] == '!') { + styler.ColourTo(endLine, SCE_DIFF_CHANGED); + } else if (lineBuffer[0] != ' ') { + styler.ColourTo(endLine, SCE_DIFF_COMMENT); + } else { + styler.ColourTo(endLine, SCE_DIFF_DEFAULT); + } +} + +static void ColouriseDiffDoc(Sci_PositionU startPos, Sci_Position length, int, WordList *[], Accessor &styler) { + char lineBuffer[DIFF_BUFFER_START_SIZE] = ""; + styler.StartAt(startPos); + styler.StartSegment(startPos); + Sci_PositionU linePos = 0; + for (Sci_PositionU i = startPos; i < startPos + length; i++) { + if (AtEOL(styler, i)) { + if (linePos < DIFF_BUFFER_START_SIZE) { + lineBuffer[linePos] = 0; + } + ColouriseDiffLine(lineBuffer, i, styler); + linePos = 0; + } else if (linePos < DIFF_BUFFER_START_SIZE - 1) { + lineBuffer[linePos++] = styler[i]; + } else if (linePos == DIFF_BUFFER_START_SIZE - 1) { + lineBuffer[linePos++] = 0; + } + } + if (linePos > 0) { // Last line does not have ending characters + if (linePos < DIFF_BUFFER_START_SIZE) { + lineBuffer[linePos] = 0; + } + ColouriseDiffLine(lineBuffer, startPos + length - 1, styler); + } +} + +static void FoldDiffDoc(Sci_PositionU startPos, Sci_Position length, int, WordList *[], Accessor &styler) { + Sci_Position curLine = styler.GetLine(startPos); + Sci_Position curLineStart = styler.LineStart(curLine); + int prevLevel = curLine > 0 ? styler.LevelAt(curLine - 1) : SC_FOLDLEVELBASE; + int nextLevel; + + do { + int lineType = styler.StyleAt(curLineStart); + if (lineType == SCE_DIFF_COMMAND) + nextLevel = SC_FOLDLEVELBASE | SC_FOLDLEVELHEADERFLAG; + else if (lineType == SCE_DIFF_HEADER) + nextLevel = (SC_FOLDLEVELBASE + 1) | SC_FOLDLEVELHEADERFLAG; + else if (lineType == SCE_DIFF_POSITION && styler[curLineStart] != '-') + nextLevel = (SC_FOLDLEVELBASE + 2) | SC_FOLDLEVELHEADERFLAG; + else if (prevLevel & SC_FOLDLEVELHEADERFLAG) + nextLevel = (prevLevel & SC_FOLDLEVELNUMBERMASK) + 1; + else + nextLevel = prevLevel; + + if ((nextLevel & SC_FOLDLEVELHEADERFLAG) && (nextLevel == prevLevel)) + styler.SetLevel(curLine-1, prevLevel & ~SC_FOLDLEVELHEADERFLAG); + + styler.SetLevel(curLine, nextLevel); + prevLevel = nextLevel; + + curLineStart = styler.LineStart(++curLine); + } while (static_cast(startPos)+length > curLineStart); +} + +static const char *const emptyWordListDesc[] = { + 0 +}; + +LexerModule lmDiff(SCLEX_DIFF, ColouriseDiffDoc, "diff", FoldDiffDoc, emptyWordListDesc); diff --git a/src/stc/scintilla/lexers/LexECL.cxx b/src/stc/scintilla/lexers/LexECL.cxx index d8065f7226..2e5433e6e2 100644 --- a/src/stc/scintilla/lexers/LexECL.cxx +++ b/src/stc/scintilla/lexers/LexECL.cxx @@ -62,7 +62,7 @@ static bool IsSpaceEquiv(int state) { } } -static void ColouriseEclDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[], +static void ColouriseEclDoc(Sci_PositionU startPos, Sci_Position length, int initStyle, WordList *keywordlists[], Accessor &styler) { WordList &keywords0 = *keywordlists[0]; WordList &keywords1 = *keywordlists[1]; @@ -90,7 +90,7 @@ static void ColouriseEclDoc(unsigned int startPos, int length, int initStyle, Wo if (initStyle == SCE_ECL_PREPROCESSOR) { // Set continuationLine if last character of previous line is '\' - int lineCurrent = styler.GetLine(startPos); + Sci_Position lineCurrent = styler.GetLine(startPos); if (lineCurrent > 0) { int chBack = styler.SafeGetCharAt(startPos-1, 0); int chBack2 = styler.SafeGetCharAt(startPos-2, 0); @@ -106,7 +106,7 @@ static void ColouriseEclDoc(unsigned int startPos, int length, int initStyle, Wo // look back to set chPrevNonWhite properly for better regex colouring if (startPos > 0) { - int back = startPos; + Sci_Position back = startPos; while (--back && IsSpaceEquiv(styler.StyleAt(back))) ; if (styler.StyleAt(back) == SCE_ECL_OPERATOR) { @@ -175,7 +175,7 @@ static void ColouriseEclDoc(unsigned int startPos, int length, int initStyle, Wo } 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(unsigned int startPos, int length, int initStyle, Wo s2[i + 1] = 0; if (keywords3.InList(s2)) { sc.ChangeState(SCE_ECL_WORD3); - } + } } sc.SetState(SCE_ECL_DEFAULT); } @@ -311,7 +311,7 @@ static void ColouriseEclDoc(unsigned int startPos, int length, int initStyle, Wo } // Determine if a new state should be entered. - int lineCurrent = styler.GetLine(sc.currentPos); + Sci_Position lineCurrent = styler.GetLine(sc.currentPos); int lineState = styler.GetLineState(lineCurrent); if (sc.state == SCE_ECL_DEFAULT) { if (lineState) { @@ -388,12 +388,12 @@ static bool IsStreamCommentStyle(int style) { style == SCE_ECL_COMMENTDOCKEYWORDERROR; } -bool MatchNoCase(Accessor & styler, unsigned int & pos, const char *s) { - int i=0; +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,15 +405,15 @@ bool MatchNoCase(Accessor & styler, unsigned int & 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(unsigned int startPos, int length, int initStyle, +static void FoldEclDoc(Sci_PositionU startPos, Sci_Position length, int initStyle, WordList *[], Accessor &styler) { bool foldComment = true; bool foldPreprocessor = true; bool foldCompact = true; bool foldAtElse = true; - unsigned int endPos = startPos + length; + Sci_PositionU endPos = startPos + length; int visibleChars = 0; - int lineCurrent = styler.GetLine(startPos); + Sci_Position lineCurrent = styler.GetLine(startPos); int levelCurrent = SC_FOLDLEVELBASE; if (lineCurrent > 0) levelCurrent = styler.LevelAt(lineCurrent-1) >> 16; @@ -422,7 +422,7 @@ static void FoldEclDoc(unsigned int startPos, int length, int initStyle, char chNext = styler[startPos]; int styleNext = styler.StyleAt(startPos); int style = initStyle; - for (unsigned int i = startPos; i < endPos; i++) { + for (Sci_PositionU i = startPos; i < endPos; i++) { char ch = chNext; chNext = styler.SafeGetCharAt(i + 1); int stylePrev = style; @@ -449,7 +449,7 @@ static void FoldEclDoc(unsigned int startPos, int length, int initStyle, } if (foldPreprocessor && (style == SCE_ECL_PREPROCESSOR)) { if (ch == '#') { - unsigned int j = i + 1; + Sci_PositionU j = i + 1; while ((j < endPos) && IsASpaceOrTab(styler.SafeGetCharAt(j))) { j++; } @@ -473,7 +473,7 @@ static void FoldEclDoc(unsigned int startPos, int length, int initStyle, } } 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++; @@ -497,7 +497,7 @@ static void FoldEclDoc(unsigned int startPos, int length, int initStyle, lineCurrent++; levelCurrent = levelNext; levelMinCurrent = levelCurrent; - if (atEOL && (i == static_cast(styler.Length()-1))) { + if (atEOL && (i == static_cast(styler.Length()-1))) { // There is an empty line at end of file so give it same level and empty styler.SetLevel(lineCurrent, (levelCurrent | levelCurrent << 16) | SC_FOLDLEVELWHITEFLAG); } diff --git a/src/stc/scintilla/lexers/LexEScript.cxx b/src/stc/scintilla/lexers/LexEScript.cxx index 28466bc8e0..bc1fb3201b 100644 --- a/src/stc/scintilla/lexers/LexEScript.cxx +++ b/src/stc/scintilla/lexers/LexEScript.cxx @@ -37,7 +37,7 @@ static inline bool IsAWordStart(const int ch) { -static void ColouriseESCRIPTDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[], +static void ColouriseESCRIPTDoc(Sci_PositionU startPos, Sci_Position length, int initStyle, WordList *keywordlists[], Accessor &styler) { WordList &keywords = *keywordlists[0]; @@ -176,24 +176,24 @@ static bool IsStreamCommentStyle(int style) { style == SCE_ESCRIPT_COMMENTLINE; } -static void FoldESCRIPTDoc(unsigned int startPos, int length, int initStyle, WordList *[], Accessor &styler) { +static void FoldESCRIPTDoc(Sci_PositionU startPos, Sci_Position length, int initStyle, WordList *[], Accessor &styler) { //~ bool foldComment = styler.GetPropertyInt("fold.comment") != 0; // Do not know how to fold the comment at the moment. bool foldCompact = styler.GetPropertyInt("fold.compact", 1) != 0; bool foldComment = true; - unsigned int endPos = startPos + length; + Sci_PositionU endPos = startPos + length; int visibleChars = 0; - int lineCurrent = styler.GetLine(startPos); + Sci_Position lineCurrent = styler.GetLine(startPos); int levelPrev = styler.LevelAt(lineCurrent) & SC_FOLDLEVELNUMBERMASK; int levelCurrent = levelPrev; char chNext = styler[startPos]; int styleNext = styler.StyleAt(startPos); int style = initStyle; - int lastStart = 0; + Sci_Position lastStart = 0; char prevWord[32] = ""; - for (unsigned int i = startPos; i < endPos; i++) { + for (Sci_PositionU i = startPos; i < endPos; i++) { char ch = chNext; chNext = styler.SafeGetCharAt(i + 1); int stylePrev = style; @@ -231,7 +231,7 @@ static void FoldESCRIPTDoc(unsigned int startPos, int length, int initStyle, Wor if (style == SCE_ESCRIPT_WORD3) { if(iswordchar(ch) && !iswordchar(chNext)) { char s[32]; - unsigned int j; + Sci_PositionU j; for(j = 0; ( j < 31 ) && ( j < i-lastStart+1 ); j++) { s[j] = static_cast(tolower(styler[lastStart + j])); } diff --git a/src/stc/scintilla/lexers/LexEiffel.cxx b/src/stc/scintilla/lexers/LexEiffel.cxx index 067801ca8d..2e2813ef6a 100644 --- a/src/stc/scintilla/lexers/LexEiffel.cxx +++ b/src/stc/scintilla/lexers/LexEiffel.cxx @@ -46,8 +46,8 @@ static inline bool IsAWordStart(unsigned int ch) { return (ch < 0x80) && (isalnum(ch) || ch == '_'); } -static void ColouriseEiffelDoc(unsigned int startPos, - int length, +static void ColouriseEiffelDoc(Sci_PositionU startPos, + Sci_Position length, int initStyle, WordList *keywordlists[], Accessor &styler) { @@ -118,16 +118,16 @@ static void ColouriseEiffelDoc(unsigned int startPos, sc.Complete(); } -static bool IsEiffelComment(Accessor &styler, int pos, int len) { +static bool IsEiffelComment(Accessor &styler, Sci_Position pos, Sci_Position len) { return len>1 && styler[pos]=='-' && styler[pos+1]=='-'; } -static void FoldEiffelDocIndent(unsigned int startPos, int length, int, +static void FoldEiffelDocIndent(Sci_PositionU startPos, Sci_Position length, int, WordList *[], Accessor &styler) { - int lengthDoc = startPos + length; + Sci_Position lengthDoc = startPos + length; // Backtrack to previous line in case need to fix its fold status - int lineCurrent = styler.GetLine(startPos); + Sci_Position lineCurrent = styler.GetLine(startPos); if (startPos > 0) { if (lineCurrent > 0) { lineCurrent--; @@ -137,7 +137,7 @@ static void FoldEiffelDocIndent(unsigned int startPos, int length, int, int spaceFlags = 0; int indentCurrent = styler.IndentAmount(lineCurrent, &spaceFlags, IsEiffelComment); char chNext = styler[startPos]; - for (int i = startPos; i < lengthDoc; i++) { + for (Sci_Position i = startPos; i < lengthDoc; i++) { char ch = chNext; chNext = styler.SafeGetCharAt(i + 1); @@ -164,11 +164,11 @@ static void FoldEiffelDocIndent(unsigned int startPos, int length, int, } } -static void FoldEiffelDocKeyWords(unsigned int startPos, int length, int /* initStyle */, WordList *[], +static void FoldEiffelDocKeyWords(Sci_PositionU startPos, Sci_Position length, int /* initStyle */, WordList *[], Accessor &styler) { - unsigned int lengthDoc = startPos + length; + Sci_PositionU lengthDoc = startPos + length; int visibleChars = 0; - int lineCurrent = styler.GetLine(startPos); + Sci_Position lineCurrent = styler.GetLine(startPos); int levelPrev = styler.LevelAt(lineCurrent) & SC_FOLDLEVELNUMBERMASK; int levelCurrent = levelPrev; char chNext = styler[startPos]; @@ -177,7 +177,7 @@ static void FoldEiffelDocKeyWords(unsigned int startPos, int length, int /* init // lastDeferred should be determined by looking back to last keyword in case // the "deferred" is on a line before "class" bool lastDeferred = false; - for (unsigned int i = startPos; i < lengthDoc; i++) { + for (Sci_PositionU i = startPos; i < lengthDoc; i++) { char ch = chNext; chNext = styler.SafeGetCharAt(i + 1); int style = styleNext; @@ -185,7 +185,7 @@ static void FoldEiffelDocKeyWords(unsigned int startPos, int length, int /* init bool atEOL = (ch == '\r' && chNext != '\n') || (ch == '\n'); if ((stylePrev != SCE_EIFFEL_WORD) && (style == SCE_EIFFEL_WORD)) { char s[20]; - unsigned int j = 0; + Sci_PositionU j = 0; while ((j < (sizeof(s) - 1)) && (iswordchar(styler[i + j]))) { s[j] = styler[i + j]; j++; diff --git a/src/stc/scintilla/lexers/LexErlang.cxx b/src/stc/scintilla/lexers/LexErlang.cxx index 5f52258594..3d3c1e89ff 100644 --- a/src/stc/scintilla/lexers/LexErlang.cxx +++ b/src/stc/scintilla/lexers/LexErlang.cxx @@ -75,7 +75,7 @@ static inline bool IsAWordChar(const int ch) { return (ch < 0x80) && (ch != ' ') && (isalnum(ch) || ch == '_'); } -static void ColouriseErlangDoc(unsigned int startPos, int length, int initStyle, +static void ColouriseErlangDoc(Sci_PositionU startPos, Sci_Position length, int initStyle, WordList *keywordlists[], Accessor &styler) { StyleContext sc(startPos, length, initStyle, styler); @@ -500,7 +500,7 @@ static void ColouriseErlangDoc(unsigned int startPos, int length, int initStyle, static int ClassifyErlangFoldPoint( Accessor &styler, int styleNext, - int keyword_start + Sci_Position keyword_start ) { int lev = 0; if (styler.Match(keyword_start,"case") @@ -521,23 +521,23 @@ static int ClassifyErlangFoldPoint( } static void FoldErlangDoc( - unsigned int startPos, int length, int initStyle, + Sci_PositionU startPos, Sci_Position length, int initStyle, WordList** /*keywordlists*/, Accessor &styler ) { - unsigned int endPos = startPos + length; - int currentLine = styler.GetLine(startPos); + Sci_PositionU endPos = startPos + length; + Sci_Position currentLine = styler.GetLine(startPos); int lev; int previousLevel = styler.LevelAt(currentLine) & SC_FOLDLEVELNUMBERMASK; int currentLevel = previousLevel; int styleNext = styler.StyleAt(startPos); int style = initStyle; int stylePrev; - int keyword_start = 0; + Sci_Position keyword_start = 0; char ch; char chNext = styler.SafeGetCharAt(startPos); bool atEOL; - for (unsigned int i = startPos; i < endPos; i++) { + for (Sci_PositionU i = startPos; i < endPos; i++) { ch = chNext; chNext = styler.SafeGetCharAt(i + 1); diff --git a/src/stc/scintilla/lexers/LexErrorList.cxx b/src/stc/scintilla/lexers/LexErrorList.cxx new file mode 100644 index 0000000000..d6fe5ee77e --- /dev/null +++ b/src/stc/scintilla/lexers/LexErrorList.cxx @@ -0,0 +1,390 @@ +// Scintilla source code edit control +/** @file LexErrorList.cxx + ** Lexer for error lists. Used for the output pane in SciTE. + **/ +// Copyright 1998-2001 by Neil Hodgson +// The License.txt file describes the conditions under which this software may be distributed. + +#include +#include +#include +#include +#include +#include + +#include "ILexer.h" +#include "Scintilla.h" +#include "SciLexer.h" + +#include "WordList.h" +#include "LexAccessor.h" +#include "Accessor.h" +#include "StyleContext.h" +#include "CharacterSet.h" +#include "LexerModule.h" + +#ifdef SCI_NAMESPACE +using namespace Scintilla; +#endif + +static bool strstart(const char *haystack, const char *needle) { + return strncmp(haystack, needle, strlen(needle)) == 0; +} + +static bool Is0To9(char ch) { + return (ch >= '0') && (ch <= '9'); +} + +static bool Is1To9(char ch) { + return (ch >= '1') && (ch <= '9'); +} + +static bool IsAlphabetic(int ch) { + return IsASCII(ch) && isalpha(ch); +} + +static inline bool AtEOL(Accessor &styler, Sci_PositionU i) { + return (styler[i] == '\n') || + ((styler[i] == '\r') && (styler.SafeGetCharAt(i + 1) != '\n')); +} + +static int RecogniseErrorListLine(const char *lineBuffer, Sci_PositionU lengthLine, Sci_Position &startValue) { + if (lineBuffer[0] == '>') { + // Command or return status + return SCE_ERR_CMD; + } else if (lineBuffer[0] == '<') { + // Diff removal. + return SCE_ERR_DIFF_DELETION; + } else if (lineBuffer[0] == '!') { + return SCE_ERR_DIFF_CHANGED; + } else if (lineBuffer[0] == '+') { + if (strstart(lineBuffer, "+++ ")) { + return SCE_ERR_DIFF_MESSAGE; + } else { + return SCE_ERR_DIFF_ADDITION; + } + } else if (lineBuffer[0] == '-') { + if (strstart(lineBuffer, "--- ")) { + return SCE_ERR_DIFF_MESSAGE; + } else { + return SCE_ERR_DIFF_DELETION; + } + } else if (strstart(lineBuffer, "cf90-")) { + // Absoft Pro Fortran 90/95 v8.2 error and/or warning message + return SCE_ERR_ABSF; + } else if (strstart(lineBuffer, "fortcom:")) { + // Intel Fortran Compiler v8.0 error/warning message + return SCE_ERR_IFORT; + } else if (strstr(lineBuffer, "File \"") && strstr(lineBuffer, ", line ")) { + return SCE_ERR_PYTHON; + } else if (strstr(lineBuffer, " in ") && strstr(lineBuffer, " on line ")) { + return SCE_ERR_PHP; + } else if ((strstart(lineBuffer, "Error ") || + strstart(lineBuffer, "Warning ")) && + strstr(lineBuffer, " at (") && + strstr(lineBuffer, ") : ") && + (strstr(lineBuffer, " at (") < strstr(lineBuffer, ") : "))) { + // Intel Fortran Compiler error/warning message + return SCE_ERR_IFC; + } else if (strstart(lineBuffer, "Error ")) { + // Borland error message + return SCE_ERR_BORLAND; + } else if (strstart(lineBuffer, "Warning ")) { + // Borland warning message + return SCE_ERR_BORLAND; + } else if (strstr(lineBuffer, "at line ") && + (strstr(lineBuffer, "at line ") < (lineBuffer + lengthLine)) && + strstr(lineBuffer, "file ") && + (strstr(lineBuffer, "file ") < (lineBuffer + lengthLine))) { + // Lua 4 error message + return SCE_ERR_LUA; + } else if (strstr(lineBuffer, " at ") && + (strstr(lineBuffer, " at ") < (lineBuffer + lengthLine)) && + strstr(lineBuffer, " line ") && + (strstr(lineBuffer, " line ") < (lineBuffer + lengthLine)) && + (strstr(lineBuffer, " at ") + 4 < (strstr(lineBuffer, " line ")))) { + // perl error message: + // at line + return SCE_ERR_PERL; + } else if ((memcmp(lineBuffer, " at ", 6) == 0) && + strstr(lineBuffer, ":line ")) { + // A .NET traceback + return SCE_ERR_NET; + } else if (strstart(lineBuffer, "Line ") && + strstr(lineBuffer, ", file ")) { + // Essential Lahey Fortran error message + return SCE_ERR_ELF; + } else if (strstart(lineBuffer, "line ") && + strstr(lineBuffer, " column ")) { + // HTML tidy style: line 42 column 1 + return SCE_ERR_TIDY; + } else if (strstart(lineBuffer, "\tat ") && + strstr(lineBuffer, "(") && + strstr(lineBuffer, ".java:")) { + // Java stack back trace + return SCE_ERR_JAVA_STACK; + } else if (strstart(lineBuffer, "In file included from ") || + 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: :: + // Microsoft: () : + // Common: (): warning|error|note|remark|catastrophic|fatal + // Common: () warning|error|note|remark|catastrophic|fatal + // Microsoft: (,) + // CTags: \t\t + // Lua 5 traceback: \t:: + // Lua 5.1: : :: + bool initialTab = (lineBuffer[0] == '\t'); + bool initialColonPart = false; + bool canBeCtags = !initialTab; // For ctags must have an identifier with no spaces then a tab + enum { stInitial, + stGccStart, stGccDigit, stGccColumn, stGcc, + stMsStart, stMsDigit, stMsBracket, stMsVc, stMsDigitComma, stMsDotNet, + stCtagsStart, stCtagsFile, stCtagsStartString, stCtagsStringDollar, stCtags, + stUnrecognized + } state = stInitial; + for (Sci_PositionU i = 0; i < lengthLine; i++) { + char ch = lineBuffer[i]; + char chNext = ' '; + if ((i + 1) < lengthLine) + chNext = lineBuffer[i + 1]; + if (state == stInitial) { + if (ch == ':') { + // May be GCC, or might be Lua 5 (Lua traceback same but with tab prefix) + if ((chNext != '\\') && (chNext != '/') && (chNext != ' ')) { + // This check is not completely accurate as may be on + // GTK+ with a file name that includes ':'. + state = stGccStart; + } else if (chNext == ' ') { // indicates a Lua 5.1 error message + initialColonPart = true; + } + } else if ((ch == '(') && Is1To9(chNext) && (!initialTab)) { + // May be Microsoft + // Check against '0' often removes phone numbers + state = stMsStart; + } else if ((ch == '\t') && canBeCtags) { + // May be CTags + state = stCtagsStart; + } else if (ch == ' ') { + canBeCtags = false; + } + } else if (state == stGccStart) { // : + state = Is0To9(ch) ? stGccDigit : stUnrecognized; + } else if (state == stGccDigit) { // : + if (ch == ':') { + state = stGccColumn; // :9.*: is GCC + startValue = i + 1; + } else if (!Is0To9(ch)) { + state = stUnrecognized; + } + } else if (state == stGccColumn) { // :: + if (!Is0To9(ch)) { + state = stGcc; + if (ch == ':') + startValue = i + 1; + break; + } + } else if (state == stMsStart) { // ( + state = Is0To9(ch) ? stMsDigit : stUnrecognized; + } else if (state == stMsDigit) { // ( + if (ch == ',') { + state = stMsDigitComma; + } else if (ch == ')') { + state = stMsBracket; + } else if ((ch != ' ') && !Is0To9(ch)) { + state = stUnrecognized; + } + } else if (state == stMsBracket) { // () + if ((ch == ' ') && (chNext == ':')) { + state = stMsVc; + } else if ((ch == ':' && chNext == ' ') || (ch == ' ')) { + // Possibly Delphi.. don't test against chNext as it's one of the strings below. + char word[512]; + Sci_PositionU j, chPos; + unsigned numstep; + chPos = 0; + if (ch == ' ') + numstep = 1; // ch was ' ', handle as if it's a delphi errorline, only add 1 to i. + else + numstep = 2; // otherwise add 2. + for (j = i + numstep; j < lengthLine && IsAlphabetic(lineBuffer[j]) && chPos < sizeof(word) - 1; j++) + word[chPos++] = lineBuffer[j]; + word[chPos] = 0; + if (!CompareCaseInsensitive(word, "error") || !CompareCaseInsensitive(word, "warning") || + !CompareCaseInsensitive(word, "fatal") || !CompareCaseInsensitive(word, "catastrophic") || + !CompareCaseInsensitive(word, "note") || !CompareCaseInsensitive(word, "remark")) { + state = stMsVc; + } else { + state = stUnrecognized; + } + } else { + state = stUnrecognized; + } + } else if (state == stMsDigitComma) { // (, + if (ch == ')') { + state = stMsDotNet; + break; + } else if ((ch != ' ') && !Is0To9(ch)) { + state = stUnrecognized; + } + } else if (state == stCtagsStart) { + if (ch == '\t') { + state = stCtagsFile; + } + } else if (state == stCtagsFile) { + if ((lineBuffer[i - 1] == '\t') && + ((ch == '/' && chNext == '^') || Is0To9(ch))) { + state = stCtags; + break; + } else if ((ch == '/') && (chNext == '^')) { + state = stCtagsStartString; + } + } else if ((state == stCtagsStartString) && ((lineBuffer[i] == '$') && (lineBuffer[i + 1] == '/'))) { + state = stCtagsStringDollar; + break; + } + } + if (state == stGcc) { + return initialColonPart ? SCE_ERR_LUA : SCE_ERR_GCC; + } else if ((state == stMsVc) || (state == stMsDotNet)) { + return SCE_ERR_MS; + } else if ((state == stCtagsStringDollar) || (state == stCtags)) { + return SCE_ERR_CTAG; + } else { + return SCE_ERR_DEFAULT; + } + } +} + +#define CSI "\033[" + +namespace { + +bool SequenceEnd(int ch) { + return (ch == 0) || ((ch >= '@') && (ch <= '~')); +} + +int StyleFromSequence(const char *seq) { + int bold = 0; + int colour = 0; + while (!SequenceEnd(*seq)) { + if (Is0To9(*seq)) { + int base = *seq - '0'; + if (Is0To9(seq[1])) { + base = base * 10; + base += seq[1] - '0'; + seq++; + } + if (base == 0) { + colour = 0; + bold = 0; + } + else if (base == 1) { + bold = 1; + } + else if (base >= 30 && base <= 37) { + colour = base - 30; + } + } + seq++; + } + return SCE_ERR_ES_BLACK + bold * 8 + colour; +} + +} + +static void ColouriseErrorListLine( + char *lineBuffer, + Sci_PositionU lengthLine, + Sci_PositionU endPos, + Accessor &styler, + bool valueSeparate, + bool escapeSequences) { + Sci_Position startValue = -1; + int style = RecogniseErrorListLine(lineBuffer, lengthLine, startValue); + if (escapeSequences && strstr(lineBuffer, CSI)) { + const int startPos = endPos - lengthLine; + const char *linePortion = lineBuffer; + int startPortion = startPos; + int portionStyle = style; + while (const char *startSeq = strstr(linePortion, CSI)) { + if (startSeq > linePortion) { + styler.ColourTo(startPortion + (startSeq - linePortion), portionStyle); + } + const char *endSeq = startSeq + 2; + while (!SequenceEnd(*endSeq)) + endSeq++; + const int endSeqPosition = startPortion + (endSeq - linePortion) + 1; + switch (*endSeq) { + case 0: + styler.ColourTo(endPos, SCE_ERR_ESCSEQ_UNKNOWN); + return; + case 'm': // Colour command + styler.ColourTo(endSeqPosition, SCE_ERR_ESCSEQ); + portionStyle = StyleFromSequence(startSeq+2); + break; + case 'K': // Erase to end of line -> ignore + styler.ColourTo(endSeqPosition, SCE_ERR_ESCSEQ); + break; + default: + styler.ColourTo(endSeqPosition, SCE_ERR_ESCSEQ_UNKNOWN); + portionStyle = style; + } + startPortion = endSeqPosition; + linePortion = endSeq + 1; + } + styler.ColourTo(endPos, portionStyle); + } else { + if (valueSeparate && (startValue >= 0)) { + styler.ColourTo(endPos - (lengthLine - startValue), style); + styler.ColourTo(endPos, SCE_ERR_VALUE); + } else { + styler.ColourTo(endPos, style); + } + } +} + +static void ColouriseErrorListDoc(Sci_PositionU startPos, Sci_Position length, int, WordList *[], Accessor &styler) { + char lineBuffer[10000]; + styler.StartAt(startPos); + styler.StartSegment(startPos); + Sci_PositionU linePos = 0; + + // property lexer.errorlist.value.separate + // For lines in the output pane that are matches from Find in Files or GCC-style + // diagnostics, style the path and line number separately from the rest of the + // line with style 21 used for the rest of the line. + // This allows matched text to be more easily distinguished from its location. + bool valueSeparate = styler.GetPropertyInt("lexer.errorlist.value.separate", 0) != 0; + + // property lexer.errorlist.escape.sequences + // Set to 1 to interpret escape sequences. + const bool escapeSequences = styler.GetPropertyInt("lexer.errorlist.escape.sequences") != 0; + + for (Sci_PositionU i = startPos; i < startPos + length; i++) { + lineBuffer[linePos++] = styler[i]; + if (AtEOL(styler, i) || (linePos >= sizeof(lineBuffer) - 1)) { + // End of line (or of line buffer) met, colourise it + lineBuffer[linePos] = '\0'; + ColouriseErrorListLine(lineBuffer, linePos, i, styler, valueSeparate, escapeSequences); + linePos = 0; + } + } + if (linePos > 0) { // Last line does not have ending characters + lineBuffer[linePos] = '\0'; + ColouriseErrorListLine(lineBuffer, linePos, startPos + length - 1, styler, valueSeparate, escapeSequences); + } +} + +static const char *const emptyWordListDesc[] = { + 0 +}; + +LexerModule lmErrorList(SCLEX_ERRORLIST, ColouriseErrorListDoc, "errorlist", 0, emptyWordListDesc); diff --git a/src/stc/scintilla/lexers/LexFlagship.cxx b/src/stc/scintilla/lexers/LexFlagship.cxx index b8568b05af..6f6f4c0c73 100644 --- a/src/stc/scintilla/lexers/LexFlagship.cxx +++ b/src/stc/scintilla/lexers/LexFlagship.cxx @@ -37,7 +37,7 @@ static inline bool IsAWordChar(int ch) (isalnum(ch) || ch == '_'); } -static void ColouriseFlagShipDoc(unsigned int startPos, int length, int initStyle, +static void ColouriseFlagShipDoc(Sci_PositionU startPos, Sci_Position length, int initStyle, WordList *keywordlists[], Accessor &styler) { @@ -271,9 +271,9 @@ static void ColouriseFlagShipDoc(unsigned int startPos, int length, int initStyl } } } else if (bEnableCode && sc.ch == '{') { - int p = 0; + Sci_Position p = 0; int chSeek; - unsigned int endPos(startPos + length); + Sci_PositionU endPos(startPos + length); do { // Skip whitespace chSeek = sc.GetRelative(++p); } while (IsASpaceOrTab(chSeek) && (sc.currentPos + p < endPos)); @@ -302,14 +302,14 @@ static void ColouriseFlagShipDoc(unsigned int startPos, int length, int initStyl sc.Complete(); } -static void FoldFlagShipDoc(unsigned int startPos, int length, int, +static void FoldFlagShipDoc(Sci_PositionU startPos, Sci_Position length, int, WordList *[], Accessor &styler) { - int endPos = startPos + length; + Sci_Position endPos = startPos + length; // Backtrack to previous line in case need to fix its fold status - int lineCurrent = styler.GetLine(startPos); + Sci_Position lineCurrent = styler.GetLine(startPos); if (startPos > 0 && lineCurrent > 0) { lineCurrent--; startPos = styler.LineStart(lineCurrent); @@ -317,7 +317,7 @@ static void FoldFlagShipDoc(unsigned int startPos, int length, int, int spaceFlags = 0; int indentCurrent = styler.IndentAmount(lineCurrent, &spaceFlags); char chNext = styler[startPos]; - for (int i = startPos; i < endPos; i++) { + for (Sci_Position i = startPos; i < endPos; i++) { char ch = chNext; chNext = styler.SafeGetCharAt(i + 1); diff --git a/src/stc/scintilla/lexers/LexForth.cxx b/src/stc/scintilla/lexers/LexForth.cxx index 7b41aaf8e7..63d3f4f6de 100644 --- a/src/stc/scintilla/lexers/LexForth.cxx +++ b/src/stc/scintilla/lexers/LexForth.cxx @@ -39,7 +39,7 @@ static inline bool IsASpaceChar(int ch) { return (ch < 0x80) && isspace(ch); } -static void ColouriseForthDoc(unsigned int startPos, int length, int initStyle, WordList *keywordLists[], +static void ColouriseForthDoc(Sci_PositionU startPos, Sci_Position length, int initStyle, WordList *keywordLists[], Accessor &styler) { WordList &control = *keywordLists[0]; @@ -151,7 +151,7 @@ static void ColouriseForthDoc(unsigned int startPos, int length, int initStyle, sc.Complete(); } -static void FoldForthDoc(unsigned int, int, int, WordList *[], +static void FoldForthDoc(Sci_PositionU, Sci_Position, int, WordList *[], Accessor &) { } diff --git a/src/stc/scintilla/lexers/LexFortran.cxx b/src/stc/scintilla/lexers/LexFortran.cxx index 5deaf11737..37e0b45c55 100644 --- a/src/stc/scintilla/lexers/LexFortran.cxx +++ b/src/stc/scintilla/lexers/LexFortran.cxx @@ -46,7 +46,7 @@ static inline bool IsALineEnd(char ch) { return ((ch == '\n') || (ch == '\r')) ; } /***************************************/ -static unsigned int GetContinuedPos(unsigned int pos, Accessor &styler) { +static Sci_PositionU GetContinuedPos(Sci_PositionU pos, Accessor &styler) { while (!IsALineEnd(styler.SafeGetCharAt(pos++))) continue; if (styler.SafeGetCharAt(pos) == '\n') pos++; while (IsABlank(styler.SafeGetCharAt(pos++))) continue; @@ -59,14 +59,15 @@ static unsigned int GetContinuedPos(unsigned int pos, Accessor &styler) { } } /***************************************/ -static void ColouriseFortranDoc(unsigned int startPos, int length, int initStyle, +static void ColouriseFortranDoc(Sci_PositionU startPos, Sci_Position length, int initStyle, WordList *keywordlists[], Accessor &styler, bool isFixFormat) { WordList &keywords = *keywordlists[0]; WordList &keywords2 = *keywordlists[1]; WordList &keywords3 = *keywordlists[2]; /***************************************/ - int posLineStart = 0, numNonBlank = 0, prevState = 0; - int endPos = startPos + length; + Sci_Position posLineStart = 0; + int numNonBlank = 0, prevState = 0; + Sci_Position endPos = startPos + length; /***************************************/ // backtrack to the nearest keyword while ((startPos > 1) && (styler.StyleAt(startPos) != SCE_F_WORD)) { @@ -86,7 +87,7 @@ static void ColouriseFortranDoc(unsigned int startPos, int length, int initStyle if (!IsASpaceOrTab(sc.ch)) numNonBlank ++; /***********************************************/ // Handle the fix format generically - int toLineStart = sc.currentPos - posLineStart; + Sci_Position toLineStart = sc.currentPos - posLineStart; if (isFixFormat && (toLineStart < 6 || toLineStart >= 72)) { if ((toLineStart == 0 && (tolower(sc.ch) == 'c' || sc.ch == '*')) || sc.ch == '!') { if (sc.MatchIgnoreCase("cdec$") || sc.MatchIgnoreCase("*dec$") || sc.MatchIgnoreCase("!dec$") || @@ -130,7 +131,7 @@ static void ColouriseFortranDoc(unsigned int startPos, int length, int initStyle // Handle line continuation generically. if (!isFixFormat && sc.ch == '&' && sc.state != SCE_F_COMMENT) { char chTemp = ' '; - int j = 1; + Sci_Position j = 1; while (IsABlank(chTemp) && j<132) { chTemp = static_cast(sc.GetRelative(j)); j++; @@ -260,6 +261,7 @@ static int classifyFoldPointFortran(const char* s, const char* prevWord, const c lev = 0; } else if (strcmp(s, "associate") == 0 || strcmp(s, "block") == 0 || strcmp(s, "blockdata") == 0 || strcmp(s, "select") == 0 + || strcmp(s, "selecttype") == 0 || strcmp(s, "selectcase") == 0 || strcmp(s, "do") == 0 || strcmp(s, "enum") ==0 || strcmp(s, "function") == 0 || strcmp(s, "interface") == 0 || strcmp(s, "module") == 0 || strcmp(s, "program") == 0 @@ -294,16 +296,16 @@ static int classifyFoldPointFortran(const char* s, const char* prevWord, const c } /***************************************/ // Folding the code -static void FoldFortranDoc(unsigned int startPos, int length, int initStyle, +static void FoldFortranDoc(Sci_PositionU startPos, Sci_Position length, int initStyle, Accessor &styler, bool isFixFormat) { // // bool foldComment = styler.GetPropertyInt("fold.comment") != 0; // Do not know how to fold the comment at the moment. // bool foldCompact = styler.GetPropertyInt("fold.compact", 1) != 0; - unsigned int endPos = startPos + length; + Sci_PositionU endPos = startPos + length; int visibleChars = 0; - int lineCurrent = styler.GetLine(startPos); + Sci_Position lineCurrent = styler.GetLine(startPos); int levelCurrent; bool isPrevLine; if (lineCurrent > 0) { @@ -320,10 +322,10 @@ static void FoldFortranDoc(unsigned int startPos, int length, int initStyle, int style = initStyle; int levelDeltaNext = 0; /***************************************/ - int lastStart = 0; + Sci_Position lastStart = 0; char prevWord[32] = ""; /***************************************/ - for (unsigned int i = startPos; i < endPos; i++) { + for (Sci_PositionU i = startPos; i < endPos; i++) { char ch = chNext; chNext = styler.SafeGetCharAt(i + 1); char chNextNonBlank = chNext; @@ -331,7 +333,7 @@ static void FoldFortranDoc(unsigned int startPos, int length, int initStyle, if (IsALineEnd(chNextNonBlank)) { nextEOL = true; } - unsigned int j=i+1; + Sci_PositionU j=i+1; while(IsABlank(chNextNonBlank) && j(tolower(styler[lastStart+k])); } @@ -385,7 +387,7 @@ static void FoldFortranDoc(unsigned int startPos, int length, int initStyle, if (depth == 0) break; } } - int tmpLineCurrent = lineCurrent; + Sci_Position tmpLineCurrent = lineCurrent; while (j(styler[start + i]); i++; @@ -48,7 +48,7 @@ static void GetRange(unsigned int start, unsigned int end, Accessor &styler, cha s[i] = '\0'; } -static void ColouriseGAPDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[], Accessor &styler) { +static void ColouriseGAPDoc(Sci_PositionU startPos, Sci_Position length, int initStyle, WordList *keywordlists[], Accessor &styler) { WordList &keywords1 = *keywordlists[0]; WordList &keywords2 = *keywordlists[1]; @@ -197,19 +197,19 @@ static int ClassifyFoldPointGAP(const char* s) { return level; } -static void FoldGAPDoc( unsigned int startPos, int length, int initStyle, WordList** , Accessor &styler) { - unsigned int endPos = startPos + length; +static void FoldGAPDoc( Sci_PositionU startPos, Sci_Position length, int initStyle, WordList** , Accessor &styler) { + Sci_PositionU endPos = startPos + length; int visibleChars = 0; - int lineCurrent = styler.GetLine(startPos); + Sci_Position lineCurrent = styler.GetLine(startPos); int levelPrev = styler.LevelAt(lineCurrent) & SC_FOLDLEVELNUMBERMASK; int levelCurrent = levelPrev; char chNext = styler[startPos]; int styleNext = styler.StyleAt(startPos); int style = initStyle; - int lastStart = 0; + Sci_Position lastStart = 0; - for (unsigned int i = startPos; i < endPos; i++) { + for (Sci_PositionU i = startPos; i < endPos; i++) { char ch = chNext; chNext = styler.SafeGetCharAt(i + 1); int stylePrev = style; diff --git a/src/stc/scintilla/lexers/LexGui4Cli.cxx b/src/stc/scintilla/lexers/LexGui4Cli.cxx index 0b33d2d7c8..c1625160a9 100644 --- a/src/stc/scintilla/lexers/LexGui4Cli.cxx +++ b/src/stc/scintilla/lexers/LexGui4Cli.cxx @@ -68,9 +68,9 @@ inline bool isGCOperator(int ch) #define isFoldPoint(x) ((styler.LevelAt(x) & SC_FOLDLEVELNUMBERMASK) == 1024) static void colorFirstWord(WordList *keywordlists[], Accessor &styler, - StyleContext *sc, char *buff, int length, int) + StyleContext *sc, char *buff, Sci_Position length, int) { - int c = 0; + Sci_Position c = 0; while (sc->More() && isSpaceOrNL(sc->ch)) { sc->Forward(); } @@ -119,12 +119,13 @@ static void colorFirstWord(WordList *keywordlists[], Accessor &styler, // Main colorizing function called by Scintilla static void -ColouriseGui4CliDoc(unsigned int startPos, int length, int initStyle, +ColouriseGui4CliDoc(Sci_PositionU startPos, Sci_Position length, int initStyle, WordList *keywordlists[], Accessor &styler) { styler.StartAt(startPos); - int quotestart = 0, oldstate, currentline = styler.GetLine(startPos); + Sci_Position currentline = styler.GetLine(startPos); + int quotestart = 0, oldstate; styler.StartSegment(startPos); bool noforward; char buff[BUFFSIZE+1]; // buffer for command name @@ -243,20 +244,20 @@ ColouriseGui4CliDoc(unsigned int startPos, int length, int initStyle, } // Main folding function called by Scintilla - (based on props (.ini) files function) -static void FoldGui4Cli(unsigned int startPos, int length, int, +static void FoldGui4Cli(Sci_PositionU startPos, Sci_Position length, int, WordList *[], Accessor &styler) { bool foldCompact = styler.GetPropertyInt("fold.compact", 1) != 0; - unsigned int endPos = startPos + length; + Sci_PositionU endPos = startPos + length; int visibleChars = 0; - int lineCurrent = styler.GetLine(startPos); + Sci_Position lineCurrent = styler.GetLine(startPos); char chNext = styler[startPos]; int styleNext = styler.StyleAt(startPos); bool headerPoint = false; - for (unsigned int i = startPos; i < endPos; i++) + for (Sci_PositionU i = startPos; i < endPos; i++) { char ch = chNext; chNext = styler[i+1]; diff --git a/src/stc/scintilla/lexers/LexHTML.cxx b/src/stc/scintilla/lexers/LexHTML.cxx index 02047930ce..59c9e8ee4f 100644 --- a/src/stc/scintilla/lexers/LexHTML.cxx +++ b/src/stc/scintilla/lexers/LexHTML.cxx @@ -57,17 +57,17 @@ inline bool IsOperator(int ch) { return false; } -static void GetTextSegment(Accessor &styler, unsigned int start, unsigned int end, char *s, size_t len) { - unsigned int i = 0; +static void GetTextSegment(Accessor &styler, Sci_PositionU start, Sci_PositionU end, char *s, size_t len) { + Sci_PositionU i = 0; for (; (i < end - start + 1) && (i < len-1); i++) { s[i] = static_cast(MakeLowerCase(styler[start + i])); } s[i] = '\0'; } -static const char *GetNextWord(Accessor &styler, unsigned int start, char *s, size_t sLen) { +static const char *GetNextWord(Accessor &styler, Sci_PositionU start, char *s, size_t sLen) { - unsigned int i = 0; + Sci_PositionU i = 0; for (; i < sLen-1; i++) { char ch = static_cast(styler.SafeGetCharAt(start + i)); if ((i == 0) && !IsAWordStart(ch)) @@ -81,7 +81,7 @@ static const char *GetNextWord(Accessor &styler, unsigned int start, char *s, si return s; } -static script_type segIsScriptingIndicator(Accessor &styler, unsigned int start, unsigned int end, script_type prevValue) { +static script_type segIsScriptingIndicator(Accessor &styler, Sci_PositionU start, Sci_PositionU end, script_type prevValue) { char s[100]; GetTextSegment(styler, start, end, s, sizeof(s)); //Platform::DebugPrintf("Scripting indicator [%s]\n", s); @@ -110,7 +110,7 @@ static script_type segIsScriptingIndicator(Accessor &styler, unsigned int start, return prevValue; } -static int PrintScriptingIndicatorOffset(Accessor &styler, unsigned int start, unsigned int end) { +static int PrintScriptingIndicatorOffset(Accessor &styler, Sci_PositionU start, Sci_PositionU end) { int iResult = 0; char s[100]; GetTextSegment(styler, start, end, s, sizeof(s)); @@ -171,7 +171,7 @@ static int stateForPrintState(int StateToPrint) { return state; } -static inline bool IsNumber(unsigned int start, Accessor &styler) { +static inline bool IsNumber(Sci_PositionU start, Accessor &styler) { return IsADigit(styler[start]) || (styler[start] == '.') || (styler[start] == '-') || (styler[start] == '#'); } @@ -242,7 +242,7 @@ static inline bool isCommentASPState(int state) { return bResult; } -static void classifyAttribHTML(unsigned int start, unsigned int end, WordList &keywords, Accessor &styler) { +static void classifyAttribHTML(Sci_PositionU start, Sci_PositionU end, WordList &keywords, Accessor &styler) { bool wordIsNumber = IsNumber(start, styler); char chAttr = SCE_H_ATTRIBUTEUNKNOWN; if (wordIsNumber) { @@ -259,14 +259,14 @@ static void classifyAttribHTML(unsigned int start, unsigned int end, WordList &k styler.ColourTo(end, chAttr); } -static int classifyTagHTML(unsigned int start, unsigned int end, +static int classifyTagHTML(Sci_PositionU start, Sci_PositionU end, WordList &keywords, Accessor &styler, bool &tagDontFold, bool caseSensitive, bool isXml, bool allowScripts) { char withSpace[30 + 2] = " "; const char *s = withSpace + 1; // Copy after the '<' - unsigned int i = 1; - for (unsigned int cPos = start; cPos <= end && i < 30; cPos++) { + Sci_PositionU i = 1; + for (Sci_PositionU cPos = start; cPos <= end && i < 30; cPos++) { char ch = styler[cPos]; if ((ch != '<') && (ch != '/')) { withSpace[i++] = caseSensitive ? ch : static_cast(MakeLowerCase(ch)); @@ -298,7 +298,7 @@ static int classifyTagHTML(unsigned int start, unsigned int end, if (allowScripts && 0 == strcmp(s, "script")) { // check to see if this is a self-closing tag by sniffing ahead bool isSelfClose = false; - for (unsigned int cPos = end; cPos <= end + 200; cPos++) { + for (Sci_PositionU cPos = end; cPos <= end + 200; cPos++) { char ch = styler.SafeGetCharAt(cPos, '\0'); if (ch == '\0' || ch == '>') break; @@ -318,10 +318,10 @@ static int classifyTagHTML(unsigned int start, unsigned int end, return chAttr; } -static void classifyWordHTJS(unsigned int start, unsigned int end, +static void classifyWordHTJS(Sci_PositionU start, Sci_PositionU end, WordList &keywords, Accessor &styler, script_mode inScriptType) { char s[30 + 1]; - unsigned int i = 0; + Sci_PositionU i = 0; for (; i < end - start + 1 && i < 30; i++) { s[i] = styler[start + i]; } @@ -337,7 +337,7 @@ static void classifyWordHTJS(unsigned int start, unsigned int end, styler.ColourTo(end, statePrintForState(chAttr, inScriptType)); } -static int classifyWordHTVB(unsigned int start, unsigned int end, WordList &keywords, Accessor &styler, script_mode inScriptType) { +static int classifyWordHTVB(Sci_PositionU start, Sci_PositionU end, WordList &keywords, Accessor &styler, script_mode inScriptType) { char chAttr = SCE_HB_IDENTIFIER; bool wordIsNumber = IsADigit(styler[start]) || (styler[start] == '.'); if (wordIsNumber) { @@ -358,10 +358,10 @@ static int classifyWordHTVB(unsigned int start, unsigned int end, WordList &keyw return SCE_HB_DEFAULT; } -static void classifyWordHTPy(unsigned int start, unsigned int end, WordList &keywords, Accessor &styler, char *prevWord, script_mode inScriptType, bool isMako) { +static void classifyWordHTPy(Sci_PositionU start, Sci_PositionU end, WordList &keywords, Accessor &styler, char *prevWord, script_mode inScriptType, bool isMako) { bool wordIsNumber = IsADigit(styler[start]); char s[30 + 1]; - unsigned int i = 0; + Sci_PositionU i = 0; for (; i < end - start + 1 && i < 30; i++) { s[i] = styler[start + i]; } @@ -383,7 +383,7 @@ static void classifyWordHTPy(unsigned int start, unsigned int end, WordList &key // Update the word colour to default or keyword // Called when in a PHP word -static void classifyWordHTPHP(unsigned int start, unsigned int end, WordList &keywords, Accessor &styler) { +static void classifyWordHTPHP(Sci_PositionU start, Sci_PositionU end, WordList &keywords, Accessor &styler) { char chAttr = SCE_HPHP_DEFAULT; bool wordIsNumber = IsADigit(styler[start]) || (styler[start] == '.' && start+1 <= end && IsADigit(styler[start+1])); if (wordIsNumber) { @@ -397,9 +397,9 @@ static void classifyWordHTPHP(unsigned int start, unsigned int end, WordList &ke styler.ColourTo(end, chAttr); } -static bool isWordHSGML(unsigned int start, unsigned int end, WordList &keywords, Accessor &styler) { +static bool isWordHSGML(Sci_PositionU start, Sci_PositionU end, WordList &keywords, Accessor &styler) { char s[30 + 1]; - unsigned int i = 0; + Sci_PositionU i = 0; for (; i < end - start + 1 && i < 30; i++) { s[i] = styler[start + i]; } @@ -407,9 +407,9 @@ static bool isWordHSGML(unsigned int start, unsigned int end, WordList &keywords return keywords.InList(s); } -static bool isWordCdata(unsigned int start, unsigned int end, Accessor &styler) { +static bool isWordCdata(Sci_PositionU start, Sci_PositionU end, Accessor &styler) { char s[30 + 1]; - unsigned int i = 0; + Sci_PositionU i = 0; for (; i < end - start + 1 && i < 30; i++) { s[i] = styler[start + i]; } @@ -520,9 +520,9 @@ static bool isPHPStringState(int state) { (state == SCE_HPHP_COMPLEX_VARIABLE); } -static int FindPhpStringDelimiter(char *phpStringDelimiter, const int phpStringDelimiterSize, int i, const int lengthDoc, Accessor &styler, bool &isSimpleString) { - int j; - const int beginning = i - 1; +static Sci_Position FindPhpStringDelimiter(char *phpStringDelimiter, const int phpStringDelimiterSize, Sci_Position i, const Sci_Position lengthDoc, Accessor &styler, bool &isSimpleString) { + Sci_Position j; + const Sci_Position beginning = i - 1; bool isValidSimpleString = false; while (i < lengthDoc && (styler[i] == ' ' || styler[i] == '\t')) @@ -567,7 +567,7 @@ static int FindPhpStringDelimiter(char *phpStringDelimiter, const int phpStringD return j - 1; } -static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[], +static void ColouriseHyperTextDoc(Sci_PositionU startPos, Sci_Position length, int initStyle, WordList *keywordlists[], Accessor &styler, bool isXml) { WordList &keywords = *keywordlists[0]; WordList &keywords2 = *keywordlists[1]; @@ -592,7 +592,7 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty // If inside a tag, it may be a script tag, so reread from the start of line starting tag to ensure any language tags are seen if (InTagState(state)) { while ((startPos > 0) && (InTagState(styler.StyleAt(startPos - 1)))) { - int backLineStart = styler.LineStart(styler.GetLine(startPos-1)); + Sci_Position backLineStart = styler.LineStart(styler.GetLine(startPos-1)); length += startPos - backLineStart; startPos = backLineStart; } @@ -610,7 +610,7 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty } styler.StartAt(startPos); - int lineCurrent = styler.GetLine(startPos); + Sci_Position lineCurrent = styler.GetLine(startPos); int lineState; if (lineCurrent > 0) { lineState = styler.GetLineState(lineCurrent-1); @@ -695,7 +695,7 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty int chPrevNonWhite = ' '; // look back to set chPrevNonWhite properly for better regex colouring if (scriptLanguage == eScriptJS && startPos > 0) { - int back = startPos; + Sci_Position back = startPos; int style = 0; while (--back) { style = styler.StyleAt(back); @@ -709,8 +709,8 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty } styler.StartSegment(startPos); - const int lengthDoc = startPos + length; - for (int i = startPos; i < lengthDoc; i++) { + const Sci_Position lengthDoc = startPos + length; + for (Sci_Position i = startPos; i < lengthDoc; i++) { const int chPrev2 = chPrev; chPrev = ch; if (!IsASpace(ch) && state != SCE_HJ_COMMENT && @@ -746,7 +746,7 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty //Platform::DebugPrintf("state=%d, StateToPrint=%d, initStyle=%d\n", state, StateToPrint, initStyle); //if ((state == SCE_HPHP_OPERATOR) || (state == SCE_HPHP_DEFAULT) || (state == SCE_HJ_SYMBOLS) || (state == SCE_HJ_START) || (state == SCE_HJ_DEFAULT)) { if (ch == '#') { - int j = i + 1; + Sci_Position j = i + 1; while ((j < lengthDoc) && IsASpaceOrTab(styler.SafeGetCharAt(j))) { j++; } @@ -769,7 +769,7 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty } else if ((ch == '\n') && !((chNext == '\r') && (chNext2 == '\n')) && (chNext != '\n')) { // check if the number of tabs is lower than the level int Findlevel = (levelCurrent & ~SC_FOLDLEVELBASE) * 8; - for (int j = 0; Findlevel > 0; j++) { + for (Sci_Position j = 0; Findlevel > 0; j++) { char chTmp = styler.SafeGetCharAt(i + j + 1); if (chTmp == '\t') { Findlevel -= 8; @@ -875,7 +875,7 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty if (const char *tag = state == SCE_HJ_COMMENTLINE || isXml ? "script" : state == SCE_H_COMMENT ? "comment" : 0) { - int j = i + 2; + Sci_Position j = i + 2; int chr; do { chr = static_cast(*tag++); @@ -1237,7 +1237,7 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty styler.ColourTo(i - 1, StateToPrint); state = SCE_H_SGML_SIMPLESTRING; } else if ((ch == '-') && (chPrev == '-')) { - if (static_cast(styler.GetStartSegment()) <= (i - 2)) { + if (static_cast(styler.GetStartSegment()) <= (i - 2)) { styler.ColourTo(i - 2, StateToPrint); } state = SCE_H_SGML_COMMENT; @@ -2080,7 +2080,7 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty // Some of the above terminated their lexeme but since the same character starts // the same class again, only reenter if non empty segment. - bool nonEmptySegment = i >= static_cast(styler.GetStartSegment()); + bool nonEmptySegment = i >= static_cast(styler.GetStartSegment()); if (state == SCE_HB_DEFAULT) { // One of the above succeeded if ((ch == '\"') && (nonEmptySegment)) { state = SCE_HB_STRING; @@ -2136,7 +2136,7 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty break; default: StateToPrint = statePrintForState(state, inScriptType); - if (static_cast(styler.GetStartSegment()) < lengthDoc) + if (static_cast(styler.GetStartSegment()) < lengthDoc) styler.ColourTo(lengthDoc - 1, StateToPrint); break; } @@ -2148,19 +2148,19 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty } } -static void ColouriseXMLDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[], +static void ColouriseXMLDoc(Sci_PositionU startPos, Sci_Position length, int initStyle, WordList *keywordlists[], Accessor &styler) { // Passing in true because we're lexing XML ColouriseHyperTextDoc(startPos, length, initStyle, keywordlists, styler, true); } -static void ColouriseHTMLDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[], +static void ColouriseHTMLDoc(Sci_PositionU startPos, Sci_Position length, int initStyle, WordList *keywordlists[], Accessor &styler) { // Passing in false because we're notlexing XML ColouriseHyperTextDoc(startPos, length, initStyle, keywordlists, styler, false); } -static void ColourisePHPScriptDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[], +static void ColourisePHPScriptDoc(Sci_PositionU startPos, Sci_Position length, int initStyle, WordList *keywordlists[], Accessor &styler) { if (startPos == 0) initStyle = SCE_HPHP_DEFAULT; diff --git a/src/stc/scintilla/lexers/LexHaskell.cxx b/src/stc/scintilla/lexers/LexHaskell.cxx index 24355fa4e4..0dd67d0ae3 100644 --- a/src/stc/scintilla/lexers/LexHaskell.cxx +++ b/src/stc/scintilla/lexers/LexHaskell.cxx @@ -143,13 +143,13 @@ static inline int CommentBlockStyleFromNestLevel(const unsigned int nestLevel) { // Mangled version of lexlib/Accessor.cxx IndentAmount. // Modified to treat comment blocks as whitespace // plus special case for commentline/preprocessor. -static int HaskellIndentAmount(Accessor &styler, const int line) { +static int HaskellIndentAmount(Accessor &styler, const Sci_Position line) { // Determines the indentation level of the current line // Comment blocks are treated as whitespace - int pos = styler.LineStart(line); - int eol_pos = styler.LineStart(line + 1) - 1; + Sci_Position pos = styler.LineStart(line); + Sci_Position eol_pos = styler.LineStart(line + 1) - 1; char ch = styler[pos]; int style = styler.StyleAt(pos); @@ -157,7 +157,7 @@ static int HaskellIndentAmount(Accessor &styler, const int line) { int indent = 0; bool inPrevPrefix = line > 0; - int posPrev = inPrevPrefix ? styler.LineStart(line-1) : 0; + Sci_Position posPrev = inPrevPrefix ? styler.LineStart(line-1) : 0; while (( ch == ' ' || ch == '\t' || IsCommentBlockStyle(style) @@ -271,7 +271,7 @@ struct OptionSetHaskell : public OptionSet { class LexerHaskell : public ILexer { bool literate; - int firstImportLine; + Sci_Position firstImportLine; int firstImportIndent; WordList keywords; WordList ffi; @@ -347,12 +347,12 @@ class LexerHaskell : public ILexer { } } - bool LineContainsImport(const int line, Accessor &styler) const { + bool LineContainsImport(const Sci_Position line, Accessor &styler) const { if (options.foldImports) { - int currentPos = styler.LineStart(line); + Sci_Position currentPos = styler.LineStart(line); int style = styler.StyleAt(currentPos); - int eol_pos = styler.LineStart(line + 1) - 1; + Sci_Position eol_pos = styler.LineStart(line + 1) - 1; while (currentPos < eol_pos) { int ch = styler[currentPos]; @@ -374,7 +374,7 @@ class LexerHaskell : public ILexer { } } - inline int IndentAmountWithOffset(Accessor &styler, const int line) const { + inline int IndentAmountWithOffset(Accessor &styler, const Sci_Position line) const { const int indent = HaskellIndentAmount(styler, line); const int indentLevel = indent & SC_FOLDLEVELNUMBERMASK; return indentLevel <= ((firstImportIndent - 1) + SC_FOLDLEVELBASE) @@ -416,17 +416,17 @@ public: return osHaskell.DescribeProperty(name); } - int SCI_METHOD PropertySet(const char *key, const char *val); + Sci_Position SCI_METHOD PropertySet(const char *key, const char *val); const char * SCI_METHOD DescribeWordListSets() { return osHaskell.DescribeWordListSets(); } - int SCI_METHOD WordListSet(int n, const char *wl); + Sci_Position SCI_METHOD WordListSet(int n, const char *wl); - void SCI_METHOD Lex(unsigned int startPos, int length, int initStyle, IDocument *pAccess); + void SCI_METHOD Lex(Sci_PositionU startPos, Sci_Position length, int initStyle, IDocument *pAccess); - void SCI_METHOD Fold(unsigned int startPos, int length, int initStyle, IDocument *pAccess); + void SCI_METHOD Fold(Sci_PositionU startPos, Sci_Position length, int initStyle, IDocument *pAccess); void * SCI_METHOD PrivateCall(int, void *) { return 0; @@ -441,14 +441,14 @@ public: } }; -int SCI_METHOD LexerHaskell::PropertySet(const char *key, const char *val) { +Sci_Position SCI_METHOD LexerHaskell::PropertySet(const char *key, const char *val) { if (osHaskell.PropertySet(&options, key, val)) { return 0; } return -1; } -int SCI_METHOD LexerHaskell::WordListSet(int n, const char *wl) { +Sci_Position SCI_METHOD LexerHaskell::WordListSet(int n, const char *wl) { WordList *wordListN = 0; switch (n) { case 0: @@ -461,7 +461,7 @@ int SCI_METHOD LexerHaskell::WordListSet(int n, const char *wl) { wordListN = &reserved_operators; break; } - int firstModification = -1; + Sci_Position firstModification = -1; if (wordListN) { WordList wlNew; wlNew.Set(wl); @@ -473,11 +473,11 @@ int SCI_METHOD LexerHaskell::WordListSet(int n, const char *wl) { return firstModification; } -void SCI_METHOD LexerHaskell::Lex(unsigned int startPos, int length, int initStyle +void SCI_METHOD LexerHaskell::Lex(Sci_PositionU startPos, Sci_Position length, int initStyle ,IDocument *pAccess) { LexAccessor styler(pAccess); - int lineCurrent = styler.GetLine(startPos); + Sci_Position lineCurrent = styler.GetLine(startPos); HaskellLineInfo hs = HaskellLineInfo(lineCurrent ? styler.GetLineState(lineCurrent-1) : 0); @@ -961,26 +961,26 @@ void SCI_METHOD LexerHaskell::Lex(unsigned int startPos, int length, int initSty sc.Complete(); } -void SCI_METHOD LexerHaskell::Fold(unsigned int startPos, int length, int // initStyle +void SCI_METHOD LexerHaskell::Fold(Sci_PositionU startPos, Sci_Position length, int // initStyle ,IDocument *pAccess) { if (!options.fold) return; Accessor styler(pAccess, NULL); - int lineCurrent = styler.GetLine(startPos); + Sci_Position lineCurrent = styler.GetLine(startPos); if (lineCurrent <= firstImportLine) { firstImportLine = -1; // readjust first import position firstImportIndent = 0; } - const int maxPos = startPos + length; - const int maxLines = + const Sci_Position maxPos = startPos + length; + const Sci_Position maxLines = maxPos == styler.Length() ? styler.GetLine(maxPos) : styler.GetLine(maxPos - 1); // Requested last line - const int docLines = styler.GetLine(styler.Length()); // Available last line + const Sci_Position docLines = styler.GetLine(styler.Length()); // Available last line // Backtrack to previous non-blank line so we can determine indent level // for any white space lines @@ -1018,7 +1018,7 @@ void SCI_METHOD LexerHaskell::Fold(unsigned int startPos, int length, int // ini while (lineCurrent <= docLines && lineCurrent <= maxLines) { // Gather info - int lineNext = lineCurrent + 1; + Sci_Position lineNext = lineCurrent + 1; importHere = false; int indentNext = indentCurrent; @@ -1063,7 +1063,7 @@ void SCI_METHOD LexerHaskell::Fold(unsigned int startPos, int length, int // ini // which is indented more than the line after the end of // the comment-block, use the level of the block before - int skipLine = lineNext; + Sci_Position skipLine = lineNext; int skipLevel = indentNextLevel; while (--skipLine > lineCurrent) { diff --git a/src/stc/scintilla/lexers/LexHex.cxx b/src/stc/scintilla/lexers/LexHex.cxx index fe972ffe82..d549881cb6 100644 --- a/src/stc/scintilla/lexers/LexHex.cxx +++ b/src/stc/scintilla/lexers/LexHex.cxx @@ -126,37 +126,37 @@ using namespace Scintilla; static inline bool IsNewline(const int ch); static int GetHexaNibble(char hd); static int GetHexaChar(char hd1, char hd2); -static int GetHexaChar(unsigned int pos, Accessor &styler); -static bool ForwardWithinLine(StyleContext &sc, int nb = 1); -static bool PosInSameRecord(unsigned int pos1, unsigned int pos2, Accessor &styler); -static int CountByteCount(unsigned int startPos, int uncountedDigits, Accessor &styler); -static int CalcChecksum(unsigned int startPos, int cnt, bool twosCompl, Accessor &styler); +static int GetHexaChar(Sci_PositionU pos, Accessor &styler); +static bool ForwardWithinLine(StyleContext &sc, Sci_Position nb = 1); +static bool PosInSameRecord(Sci_PositionU pos1, Sci_PositionU pos2, Accessor &styler); +static Sci_Position CountByteCount(Sci_PositionU startPos, Sci_Position uncountedDigits, Accessor &styler); +static int CalcChecksum(Sci_PositionU startPos, Sci_Position cnt, bool twosCompl, Accessor &styler); // prototypes for file format specific helper functions -static unsigned int GetSrecRecStartPosition(unsigned int pos, Accessor &styler); -static int GetSrecByteCount(unsigned int recStartPos, Accessor &styler); -static int CountSrecByteCount(unsigned int recStartPos, Accessor &styler); -static int GetSrecAddressFieldSize(unsigned int recStartPos, Accessor &styler); -static int GetSrecAddressFieldType(unsigned int recStartPos, Accessor &styler); -static int GetSrecDataFieldType(unsigned int recStartPos, Accessor &styler); -static int GetSrecRequiredDataFieldSize(unsigned int recStartPos, Accessor &styler); -static int GetSrecChecksum(unsigned int recStartPos, Accessor &styler); -static int CalcSrecChecksum(unsigned int recStartPos, Accessor &styler); +static Sci_PositionU GetSrecRecStartPosition(Sci_PositionU pos, Accessor &styler); +static int GetSrecByteCount(Sci_PositionU recStartPos, Accessor &styler); +static Sci_Position CountSrecByteCount(Sci_PositionU recStartPos, Accessor &styler); +static int GetSrecAddressFieldSize(Sci_PositionU recStartPos, Accessor &styler); +static int GetSrecAddressFieldType(Sci_PositionU recStartPos, Accessor &styler); +static int GetSrecDataFieldType(Sci_PositionU recStartPos, Accessor &styler); +static Sci_Position GetSrecRequiredDataFieldSize(Sci_PositionU recStartPos, Accessor &styler); +static int GetSrecChecksum(Sci_PositionU recStartPos, Accessor &styler); +static int CalcSrecChecksum(Sci_PositionU recStartPos, Accessor &styler); -static unsigned int GetIHexRecStartPosition(unsigned int pos, Accessor &styler); -static int GetIHexByteCount(unsigned int recStartPos, Accessor &styler); -static int CountIHexByteCount(unsigned int recStartPos, Accessor &styler); -static int GetIHexAddressFieldType(unsigned int recStartPos, Accessor &styler); -static int GetIHexDataFieldType(unsigned int recStartPos, Accessor &styler); -static int GetIHexRequiredDataFieldSize(unsigned int recStartPos, Accessor &styler); -static int GetIHexChecksum(unsigned int recStartPos, Accessor &styler); -static int CalcIHexChecksum(unsigned int recStartPos, Accessor &styler); +static Sci_PositionU GetIHexRecStartPosition(Sci_PositionU pos, Accessor &styler); +static int GetIHexByteCount(Sci_PositionU recStartPos, Accessor &styler); +static Sci_Position CountIHexByteCount(Sci_PositionU recStartPos, Accessor &styler); +static int GetIHexAddressFieldType(Sci_PositionU recStartPos, Accessor &styler); +static int GetIHexDataFieldType(Sci_PositionU recStartPos, Accessor &styler); +static int GetIHexRequiredDataFieldSize(Sci_PositionU recStartPos, Accessor &styler); +static int GetIHexChecksum(Sci_PositionU recStartPos, Accessor &styler); +static int CalcIHexChecksum(Sci_PositionU recStartPos, Accessor &styler); -static int GetTEHexDigitCount(unsigned int recStartPos, Accessor &styler); -static int CountTEHexDigitCount(unsigned int recStartPos, Accessor &styler); -static int GetTEHexAddressFieldType(unsigned int recStartPos, Accessor &styler); -static int GetTEHexChecksum(unsigned int recStartPos, Accessor &styler); -static int CalcTEHexChecksum(unsigned int recStartPos, Accessor &styler); +static int GetTEHexDigitCount(Sci_PositionU recStartPos, Accessor &styler); +static Sci_Position CountTEHexDigitCount(Sci_PositionU recStartPos, Accessor &styler); +static int GetTEHexAddressFieldType(Sci_PositionU recStartPos, Accessor &styler); +static int GetTEHexChecksum(Sci_PositionU recStartPos, Accessor &styler); +static int CalcTEHexChecksum(Sci_PositionU recStartPos, Accessor &styler); static inline bool IsNewline(const int ch) { @@ -207,7 +207,7 @@ static int GetHexaChar(char hd1, char hd2) return hexValue; } -static int GetHexaChar(unsigned int pos, Accessor &styler) +static int GetHexaChar(Sci_PositionU pos, Accessor &styler) { char highNibble, lowNibble; @@ -221,9 +221,9 @@ static int GetHexaChar(unsigned int pos, Accessor &styler) // end. Return true if forwarding within the line was possible. // Avoids influence on highlighting of the subsequent line if the current line // is malformed (too short). -static bool ForwardWithinLine(StyleContext &sc, int nb) +static bool ForwardWithinLine(StyleContext &sc, Sci_Position nb) { - for (int i = 0; i < nb; i++) { + for (Sci_Position i = 0; i < nb; i++) { if (sc.atLineEnd) { // line is too short sc.SetState(SCE_HEX_DEFAULT); @@ -238,7 +238,7 @@ static bool ForwardWithinLine(StyleContext &sc, int nb) } // Checks whether the given positions are in the same record. -static bool PosInSameRecord(unsigned int pos1, unsigned int pos2, Accessor &styler) +static bool PosInSameRecord(Sci_PositionU pos1, Sci_PositionU pos2, Accessor &styler) { return styler.GetLine(pos1) == styler.GetLine(pos2); } @@ -246,10 +246,10 @@ static bool PosInSameRecord(unsigned int pos1, unsigned int pos2, Accessor &styl // Count the number of digit pairs from till end of record, ignoring // digits. // If the record is too short, a negative count may be returned. -static int CountByteCount(unsigned int startPos, int uncountedDigits, Accessor &styler) +static Sci_Position CountByteCount(Sci_PositionU startPos, Sci_Position uncountedDigits, Accessor &styler) { - int cnt; - unsigned int pos; + Sci_Position cnt; + Sci_PositionU pos; pos = startPos; @@ -258,7 +258,7 @@ static int CountByteCount(unsigned int startPos, int uncountedDigits, Accessor & } // number of digits in this line minus number of digits of uncounted fields - cnt = static_cast(pos - startPos) - uncountedDigits; + cnt = static_cast(pos - startPos) - uncountedDigits; // Prepare round up if odd (digit pair incomplete), this way the byte // count is considered to be valid if the checksum is incomplete. @@ -275,11 +275,11 @@ static int CountByteCount(unsigned int startPos, int uncountedDigits, Accessor & // Calculate the checksum of the record. // is the position of the first character of the starting digit // pair, is the number of digit pairs. -static int CalcChecksum(unsigned int startPos, int cnt, bool twosCompl, Accessor &styler) +static int CalcChecksum(Sci_PositionU startPos, Sci_Position cnt, bool twosCompl, Accessor &styler) { int cs = 0; - for (unsigned int pos = startPos; pos < startPos + cnt; pos += 2) { + for (Sci_PositionU pos = startPos; pos < startPos + cnt; pos += 2) { int val = GetHexaChar(pos, styler); if (val < 0) { @@ -301,7 +301,7 @@ static int CalcChecksum(unsigned int startPos, int cnt, bool twosCompl, Accessor // Get the position of the record "start" field (first character in line) in // the record around position . -static unsigned int GetSrecRecStartPosition(unsigned int pos, Accessor &styler) +static Sci_PositionU GetSrecRecStartPosition(Sci_PositionU pos, Accessor &styler) { while (styler.SafeGetCharAt(pos) != 'S') { pos--; @@ -312,7 +312,7 @@ static unsigned int GetSrecRecStartPosition(unsigned int pos, Accessor &styler) // Get the value of the "byte count" field, it counts the number of bytes in // the subsequent fields ("address", "data" and "checksum" fields). -static int GetSrecByteCount(unsigned int recStartPos, Accessor &styler) +static int GetSrecByteCount(Sci_PositionU recStartPos, Accessor &styler) { int val; @@ -327,13 +327,13 @@ static int GetSrecByteCount(unsigned int recStartPos, Accessor &styler) // Count the number of digit pairs for the "address", "data" and "checksum" // fields in this record. Has to be equal to the "byte count" field value. // If the record is too short, a negative count may be returned. -static int CountSrecByteCount(unsigned int recStartPos, Accessor &styler) +static Sci_Position CountSrecByteCount(Sci_PositionU recStartPos, Accessor &styler) { return CountByteCount(recStartPos, 4, styler); } // Get the size of the "address" field. -static int GetSrecAddressFieldSize(unsigned int recStartPos, Accessor &styler) +static int GetSrecAddressFieldSize(Sci_PositionU recStartPos, Accessor &styler) { switch (styler.SafeGetCharAt(recStartPos + 1)) { case '0': @@ -357,7 +357,7 @@ static int GetSrecAddressFieldSize(unsigned int recStartPos, Accessor &styler) } // Get the type of the "address" field content. -static int GetSrecAddressFieldType(unsigned int recStartPos, Accessor &styler) +static int GetSrecAddressFieldType(Sci_PositionU recStartPos, Accessor &styler) { switch (styler.SafeGetCharAt(recStartPos + 1)) { case '0': @@ -383,7 +383,7 @@ static int GetSrecAddressFieldType(unsigned int recStartPos, Accessor &styler) } // Get the type of the "data" field content. -static int GetSrecDataFieldType(unsigned int recStartPos, Accessor &styler) +static int GetSrecDataFieldType(Sci_PositionU recStartPos, Accessor &styler) { switch (styler.SafeGetCharAt(recStartPos + 1)) { case '0': @@ -407,7 +407,7 @@ static int GetSrecDataFieldType(unsigned int recStartPos, Accessor &styler) // Get the required size of the "data" field. Useless for block header and // ordinary data records (type S0, S1, S2, S3), return the value calculated // from the "byte count" and "address field" size in this case. -static int GetSrecRequiredDataFieldSize(unsigned int recStartPos, Accessor &styler) +static Sci_Position GetSrecRequiredDataFieldSize(Sci_PositionU recStartPos, Accessor &styler) { switch (styler.SafeGetCharAt(recStartPos + 1)) { case '5': @@ -425,7 +425,7 @@ static int GetSrecRequiredDataFieldSize(unsigned int recStartPos, Accessor &styl } // Get the value of the "checksum" field. -static int GetSrecChecksum(unsigned int recStartPos, Accessor &styler) +static int GetSrecChecksum(Sci_PositionU recStartPos, Accessor &styler) { int byteCount; @@ -435,9 +435,9 @@ static int GetSrecChecksum(unsigned int recStartPos, Accessor &styler) } // Calculate the checksum of the record. -static int CalcSrecChecksum(unsigned int recStartPos, Accessor &styler) +static int CalcSrecChecksum(Sci_PositionU recStartPos, Accessor &styler) { - int byteCount; + Sci_Position byteCount; byteCount = GetSrecByteCount(recStartPos, styler); @@ -447,7 +447,7 @@ static int CalcSrecChecksum(unsigned int recStartPos, Accessor &styler) // Get the position of the record "start" field (first character in line) in // the record around position . -static unsigned int GetIHexRecStartPosition(unsigned int pos, Accessor &styler) +static Sci_PositionU GetIHexRecStartPosition(Sci_PositionU pos, Accessor &styler) { while (styler.SafeGetCharAt(pos) != ':') { pos--; @@ -458,7 +458,7 @@ static unsigned int GetIHexRecStartPosition(unsigned int pos, Accessor &styler) // Get the value of the "byte count" field, it counts the number of bytes in // the "data" field. -static int GetIHexByteCount(unsigned int recStartPos, Accessor &styler) +static int GetIHexByteCount(Sci_PositionU recStartPos, Accessor &styler) { int val; @@ -473,13 +473,13 @@ static int GetIHexByteCount(unsigned int recStartPos, Accessor &styler) // Count the number of digit pairs for the "data" field in this record. Has to // be equal to the "byte count" field value. // If the record is too short, a negative count may be returned. -static int CountIHexByteCount(unsigned int recStartPos, Accessor &styler) +static Sci_Position CountIHexByteCount(Sci_PositionU recStartPos, Accessor &styler) { return CountByteCount(recStartPos, 11, styler); } // Get the type of the "address" field content. -static int GetIHexAddressFieldType(unsigned int recStartPos, Accessor &styler) +static int GetIHexAddressFieldType(Sci_PositionU recStartPos, Accessor &styler) { if (!PosInSameRecord(recStartPos, recStartPos + 7, styler)) { // malformed (record too short) @@ -504,7 +504,7 @@ static int GetIHexAddressFieldType(unsigned int recStartPos, Accessor &styler) } // Get the type of the "data" field content. -static int GetIHexDataFieldType(unsigned int recStartPos, Accessor &styler) +static int GetIHexDataFieldType(Sci_PositionU recStartPos, Accessor &styler) { switch (GetHexaChar(recStartPos + 7, styler)) { case 0x00: @@ -528,7 +528,7 @@ static int GetIHexDataFieldType(unsigned int recStartPos, Accessor &styler) // Get the required size of the "data" field. Useless for an ordinary data // record (type 00), return the "byte count" in this case. -static int GetIHexRequiredDataFieldSize(unsigned int recStartPos, Accessor &styler) +static int GetIHexRequiredDataFieldSize(Sci_PositionU recStartPos, Accessor &styler) { switch (GetHexaChar(recStartPos + 7, styler)) { case 0x01: @@ -548,7 +548,7 @@ static int GetIHexRequiredDataFieldSize(unsigned int recStartPos, Accessor &styl } // Get the value of the "checksum" field. -static int GetIHexChecksum(unsigned int recStartPos, Accessor &styler) +static int GetIHexChecksum(Sci_PositionU recStartPos, Accessor &styler) { int byteCount; @@ -558,7 +558,7 @@ static int GetIHexChecksum(unsigned int recStartPos, Accessor &styler) } // Calculate the checksum of the record. -static int CalcIHexChecksum(unsigned int recStartPos, Accessor &styler) +static int CalcIHexChecksum(Sci_PositionU recStartPos, Accessor &styler) { int byteCount; @@ -571,7 +571,7 @@ static int CalcIHexChecksum(unsigned int recStartPos, Accessor &styler) // Get the value of the "record length" field, it counts the number of digits in // the record excluding the percent. -static int GetTEHexDigitCount(unsigned int recStartPos, Accessor &styler) +static int GetTEHexDigitCount(Sci_PositionU recStartPos, Accessor &styler) { int val = GetHexaChar(recStartPos + 1, styler); if (val < 0) @@ -582,9 +582,9 @@ static int GetTEHexDigitCount(unsigned int recStartPos, Accessor &styler) // Count the number of digits in this record. Has to // be equal to the "record length" field value. -static int CountTEHexDigitCount(unsigned int recStartPos, Accessor &styler) +static Sci_Position CountTEHexDigitCount(Sci_PositionU recStartPos, Accessor &styler) { - unsigned int pos; + Sci_PositionU pos; pos = recStartPos+1; @@ -592,11 +592,11 @@ static int CountTEHexDigitCount(unsigned int recStartPos, Accessor &styler) pos++; } - return static_cast(pos - (recStartPos+1)); + return static_cast(pos - (recStartPos+1)); } // Get the type of the "address" field content. -static int GetTEHexAddressFieldType(unsigned int recStartPos, Accessor &styler) +static int GetTEHexAddressFieldType(Sci_PositionU recStartPos, Accessor &styler) { switch (styler.SafeGetCharAt(recStartPos + 3)) { case '6': @@ -611,16 +611,16 @@ static int GetTEHexAddressFieldType(unsigned int recStartPos, Accessor &styler) } // Get the value of the "checksum" field. -static int GetTEHexChecksum(unsigned int recStartPos, Accessor &styler) +static int GetTEHexChecksum(Sci_PositionU recStartPos, Accessor &styler) { return GetHexaChar(recStartPos+4, styler); } // Calculate the checksum of the record (excluding the checksum field). -static int CalcTEHexChecksum(unsigned int recStartPos, Accessor &styler) +static int CalcTEHexChecksum(Sci_PositionU recStartPos, Accessor &styler) { - unsigned int pos = recStartPos +1; - unsigned int length = GetTEHexDigitCount(recStartPos, styler); + Sci_PositionU pos = recStartPos +1; + Sci_PositionU length = GetTEHexDigitCount(recStartPos, styler); int cs = GetHexaNibble(styler.SafeGetCharAt(pos++));//length cs += GetHexaNibble(styler.SafeGetCharAt(pos++));//length @@ -645,12 +645,12 @@ static int CalcTEHexChecksum(unsigned int recStartPos, Accessor &styler) } -static void ColouriseSrecDoc(unsigned int startPos, int length, int initStyle, WordList *[], Accessor &styler) +static void ColouriseSrecDoc(Sci_PositionU startPos, Sci_Position length, int initStyle, WordList *[], Accessor &styler) { StyleContext sc(startPos, length, initStyle, styler); while (sc.More()) { - unsigned int recStartPos; + Sci_PositionU recStartPos; int byteCount, reqByteCount, addrFieldSize, addrFieldType, dataFieldSize, dataFieldType; int cs1, cs2; @@ -769,12 +769,12 @@ static void ColouriseSrecDoc(unsigned int startPos, int length, int initStyle, W sc.Complete(); } -static void ColouriseIHexDoc(unsigned int startPos, int length, int initStyle, WordList *[], Accessor &styler) +static void ColouriseIHexDoc(Sci_PositionU startPos, Sci_Position length, int initStyle, WordList *[], Accessor &styler) { StyleContext sc(startPos, length, initStyle, styler); while (sc.More()) { - unsigned int recStartPos; + Sci_PositionU recStartPos; int byteCount, addrFieldType, dataFieldSize, dataFieldType; int cs1, cs2; @@ -890,19 +890,19 @@ static void ColouriseIHexDoc(unsigned int startPos, int length, int initStyle, W sc.Complete(); } -static void FoldIHexDoc(unsigned int startPos, int length, int, WordList *[], Accessor &styler) +static void FoldIHexDoc(Sci_PositionU startPos, Sci_Position length, int, WordList *[], Accessor &styler) { - unsigned int endPos = startPos + length; + Sci_PositionU endPos = startPos + length; - int lineCurrent = styler.GetLine(startPos); + Sci_Position lineCurrent = styler.GetLine(startPos); int levelCurrent = SC_FOLDLEVELBASE; if (lineCurrent > 0) levelCurrent = styler.LevelAt(lineCurrent - 1); - unsigned int lineStartNext = styler.LineStart(lineCurrent + 1); + Sci_PositionU lineStartNext = styler.LineStart(lineCurrent + 1); int levelNext = SC_FOLDLEVELBASE; // default if no specific line found - for (unsigned int i = startPos; i < endPos; i++) { + for (Sci_PositionU i = startPos; i < endPos; i++) { bool atEOL = i == (lineStartNext - 1); int style = styler.StyleAt(i); @@ -912,7 +912,7 @@ static void FoldIHexDoc(unsigned int startPos, int length, int, WordList *[], Ac levelNext = SC_FOLDLEVELBASE | SC_FOLDLEVELHEADERFLAG; } else if (style == SCE_HEX_DATAADDRESS || (style == SCE_HEX_DEFAULT - && i == (unsigned int)styler.LineStart(lineCurrent))) { + && i == (Sci_PositionU)styler.LineStart(lineCurrent))) { // data record or no record start code at all if (levelCurrent & SC_FOLDLEVELHEADERFLAG) { levelNext = SC_FOLDLEVELBASE + 1; @@ -933,12 +933,12 @@ static void FoldIHexDoc(unsigned int startPos, int length, int, WordList *[], Ac } } -static void ColouriseTEHexDoc(unsigned int startPos, int length, int initStyle, WordList *[], Accessor &styler) +static void ColouriseTEHexDoc(Sci_PositionU startPos, Sci_Position length, int initStyle, WordList *[], Accessor &styler) { StyleContext sc(startPos, length, initStyle, styler); while (sc.More()) { - unsigned int recStartPos; + Sci_PositionU recStartPos; int digitCount, addrFieldType; int cs1, cs2; diff --git a/src/stc/scintilla/lexers/LexInno.cxx b/src/stc/scintilla/lexers/LexInno.cxx index 63fadf0ba6..50aa25d284 100644 --- a/src/stc/scintilla/lexers/LexInno.cxx +++ b/src/stc/scintilla/lexers/LexInno.cxx @@ -27,14 +27,14 @@ using namespace Scintilla; #endif -static void ColouriseInnoDoc(unsigned int startPos, int length, int, WordList *keywordLists[], Accessor &styler) { +static void ColouriseInnoDoc(Sci_PositionU startPos, Sci_Position length, int, WordList *keywordLists[], Accessor &styler) { int state = SCE_INNO_DEFAULT; char chPrev; char ch = 0; char chNext = styler[startPos]; - int lengthDoc = startPos + length; - char *buffer = new char[length]; - int bufferCount = 0; + Sci_Position lengthDoc = startPos + length; + char *buffer = new char[length+1]; + Sci_Position bufferCount = 0; bool isBOL, isEOL, isWS, isBOLWS = 0; bool isCStyleComment = false; @@ -45,7 +45,7 @@ static void ColouriseInnoDoc(unsigned int startPos, int length, int, WordList *k WordList &pascalKeywords = *keywordLists[4]; WordList &userKeywords = *keywordLists[5]; - int curLine = styler.GetLine(startPos); + Sci_Position curLine = styler.GetLine(startPos); int curLineState = curLine > 0 ? styler.GetLineState(curLine - 1) : 0; bool isCode = (curLineState == 1); @@ -53,7 +53,7 @@ static void ColouriseInnoDoc(unsigned int startPos, int length, int, WordList *k // using the hand-written state machine shown below styler.StartAt(startPos); styler.StartSegment(startPos); - for (int i = startPos; i < lengthDoc; i++) { + for (Sci_Position i = startPos; i < lengthDoc; i++) { chPrev = ch; ch = chNext; chNext = styler.SafeGetCharAt(i + 1); @@ -248,17 +248,17 @@ static const char * const innoWordListDesc[] = { 0 }; -static void FoldInnoDoc(unsigned int startPos, int length, int, WordList *[], Accessor &styler) { - unsigned int endPos = startPos + length; +static void FoldInnoDoc(Sci_PositionU startPos, Sci_Position length, int, WordList *[], Accessor &styler) { + Sci_PositionU endPos = startPos + length; char chNext = styler[startPos]; - int lineCurrent = styler.GetLine(startPos); + Sci_Position lineCurrent = styler.GetLine(startPos); bool sectionFlag = false; int levelPrev = lineCurrent > 0 ? styler.LevelAt(lineCurrent - 1) : SC_FOLDLEVELBASE; int level; - for (unsigned int i = startPos; i < endPos; i++) { + for (Sci_PositionU i = startPos; i < endPos; i++) { char ch = chNext; chNext = styler[i+1]; bool atEOL = (ch == '\r' && chNext != '\n') || (ch == '\n'); diff --git a/src/stc/scintilla/lexers/LexKVIrc.cxx b/src/stc/scintilla/lexers/LexKVIrc.cxx index 958a2cf67c..75cb8331be 100644 --- a/src/stc/scintilla/lexers/LexKVIrc.cxx +++ b/src/stc/scintilla/lexers/LexKVIrc.cxx @@ -49,7 +49,7 @@ static inline bool IsAWordStart(int ch) { /* Interface function called by Scintilla to request some text to be syntax highlighted */ -static void ColouriseKVIrcDoc(unsigned int startPos, int length, +static void ColouriseKVIrcDoc(Sci_PositionU startPos, Sci_Position length, int initStyle, WordList *keywordlists[], Accessor &styler) { @@ -313,10 +313,10 @@ static void ColouriseKVIrcDoc(unsigned int startPos, int length, * fetching the current word, NULL-terminated like * the keyword list */ char s[100]; - int wordLen = sc.currentPos - styler.GetStartSegment(); + Sci_Position wordLen = sc.currentPos - styler.GetStartSegment(); if (wordLen > 99) wordLen = 99; /* Include '\0' in buffer */ - int i; + Sci_Position i; for( i = 0; i < wordLen; ++i ) { s[i] = styler.SafeGetCharAt( styler.GetStartSegment() + i ); @@ -355,21 +355,21 @@ static void ColouriseKVIrcDoc(unsigned int startPos, int length, sc.Complete(); } -static void FoldKVIrcDoc(unsigned int startPos, int length, int /*initStyle - unused*/, +static void FoldKVIrcDoc(Sci_PositionU startPos, Sci_Position length, int /*initStyle - unused*/, WordList *[], Accessor &styler) { /* Based on CMake's folder */ - + /* Exiting if folding isnt enabled */ if ( styler.GetPropertyInt("fold") == 0 ) return; /* Obtaining current line number*/ - int currentLine = styler.GetLine(startPos); + Sci_Position currentLine = styler.GetLine(startPos); /* Obtaining starting character - indentation is done on a line basis, * not character */ - unsigned int safeStartPos = styler.LineStart( currentLine ); + Sci_PositionU safeStartPos = styler.LineStart( currentLine ); /* Initialising current level - this is defined as indentation level * in the low 12 bits, with flag bits in the upper four bits. @@ -386,7 +386,7 @@ static void FoldKVIrcDoc(unsigned int startPos, int length, int /*initStyle - un int nextLevel = currentLevel; // Looping for characters in range - for (unsigned int i = safeStartPos; i < startPos + length; ++i) + for (Sci_PositionU i = safeStartPos; i < startPos + length; ++i) { /* Folding occurs after syntax highlighting, meaning Scintilla * already knows where the comments are diff --git a/src/stc/scintilla/lexers/LexKix.cxx b/src/stc/scintilla/lexers/LexKix.cxx index dc509e4caa..82ff9a54bf 100644 --- a/src/stc/scintilla/lexers/LexKix.cxx +++ b/src/stc/scintilla/lexers/LexKix.cxx @@ -37,7 +37,7 @@ static inline bool IsOperator(const int ch) { return (ch == '+' || ch == '-' || ch == '*' || ch == '/' || ch == '&' || ch == '|' || ch == '<' || ch == '>' || ch == '='); } -static void ColouriseKixDoc(unsigned int startPos, int length, int initStyle, +static void ColouriseKixDoc(Sci_PositionU startPos, Sci_Position length, int initStyle, WordList *keywordlists[], Accessor &styler) { WordList &keywords = *keywordlists[0]; diff --git a/src/stc/scintilla/lexers/LexLaTeX.cxx b/src/stc/scintilla/lexers/LexLaTeX.cxx index f8af1e7dcc..6dc0617e14 100644 --- a/src/stc/scintilla/lexers/LexLaTeX.cxx +++ b/src/stc/scintilla/lexers/LexLaTeX.cxx @@ -48,41 +48,41 @@ struct latexFoldSave { class LexerLaTeX : public LexerBase { private: vector modes; - void setMode(int line, int mode) { - if (line >= static_cast(modes.size())) modes.resize(line + 1, 0); + void setMode(Sci_Position line, int mode) { + if (line >= static_cast(modes.size())) modes.resize(line + 1, 0); modes[line] = mode; } - int getMode(int line) { - if (line >= 0 && line < static_cast(modes.size())) return modes[line]; + int getMode(Sci_Position line) { + if (line >= 0 && line < static_cast(modes.size())) return modes[line]; return 0; } - void truncModes(int numLines) { - if (static_cast(modes.size()) > numLines * 2 + 256) + void truncModes(Sci_Position numLines) { + if (static_cast(modes.size()) > numLines * 2 + 256) modes.resize(numLines + 128); } - + vector saves; - void setSave(int line, const latexFoldSave &save) { - if (line >= static_cast(saves.size())) saves.resize(line + 1); + void setSave(Sci_Position line, const latexFoldSave &save) { + if (line >= static_cast(saves.size())) saves.resize(line + 1); saves[line] = save; } - void getSave(int line, latexFoldSave &save) { - if (line >= 0 && line < static_cast(saves.size())) save = saves[line]; + void getSave(Sci_Position line, latexFoldSave &save) { + if (line >= 0 && line < static_cast(saves.size())) save = saves[line]; else { save.structLev = 0; for (int i = 0; i < 8; ++i) save.openBegins[i] = 0; } } - void truncSaves(int numLines) { - if (static_cast(saves.size()) > numLines * 2 + 256) + void truncSaves(Sci_Position numLines) { + if (static_cast(saves.size()) > numLines * 2 + 256) saves.resize(numLines + 128); } public: static ILexer *LexerFactoryLaTeX() { return new LexerLaTeX(); } - void SCI_METHOD Lex(unsigned int startPos, int length, int initStyle, IDocument *pAccess); - void SCI_METHOD Fold(unsigned int startPos, int length, int initStyle, IDocument *pAccess); + void SCI_METHOD Lex(Sci_PositionU startPos, Sci_Position length, int initStyle, IDocument *pAccess); + void SCI_METHOD Fold(Sci_PositionU startPos, Sci_Position length, int initStyle, IDocument *pAccess); }; static bool latexIsSpecial(int ch) { @@ -102,7 +102,7 @@ static bool latexIsLetter(int ch) { return IsASCII(ch) && isalpha(ch); } -static bool latexIsTagValid(int &i, int l, Accessor &styler) { +static bool latexIsTagValid(Sci_Position &i, Sci_Position l, Accessor &styler) { while (i < l) { if (styler.SafeGetCharAt(i) == '{') { while (i < l) { @@ -122,7 +122,7 @@ static bool latexIsTagValid(int &i, int l, Accessor &styler) { return false; } -static bool latexNextNotBlankIs(int i, Accessor &styler, char needle) { +static bool latexNextNotBlankIs(Sci_Position i, Accessor &styler, char needle) { char ch; while (i < styler.Length()) { ch = styler.SafeGetCharAt(i); @@ -137,10 +137,10 @@ static bool latexNextNotBlankIs(int i, Accessor &styler, char needle) { return false; } -static bool latexLastWordIs(int start, Accessor &styler, const char *needle) { - unsigned int i = 0; - unsigned int l = static_cast(strlen(needle)); - int ini = start-l+1; +static bool latexLastWordIs(Sci_Position start, Accessor &styler, const char *needle) { + Sci_PositionU i = 0; + Sci_PositionU l = static_cast(strlen(needle)); + Sci_Position ini = start-l+1; char s[32]; while (i < l && i < 31) { @@ -152,8 +152,8 @@ static bool latexLastWordIs(int start, Accessor &styler, const char *needle) { return (strcmp(s, needle) == 0); } -static bool latexLastWordIsMathEnv(int pos, Accessor &styler) { - int i, j; +static bool latexLastWordIsMathEnv(Sci_Position pos, Accessor &styler) { + Sci_Position i, j; char s[32]; const char *mathEnvs[] = { "align", "alignat", "flalign", "gather", "multiline", "displaymath", "eqnarray", "equation" }; @@ -184,7 +184,7 @@ static inline void latexStateReset(int &mode, int &state) { // There are cases not handled correctly, like $abcd\textrm{what is $x+y$}z+w$. // But I think it's already good enough. -void SCI_METHOD LexerLaTeX::Lex(unsigned int startPos, int length, int initStyle, IDocument *pAccess) { +void SCI_METHOD LexerLaTeX::Lex(Sci_PositionU startPos, Sci_Position length, int initStyle, IDocument *pAccess) { // startPos is assumed to be the first character of a line Accessor styler(pAccess, &props); styler.StartAt(startPos); @@ -192,13 +192,13 @@ void SCI_METHOD LexerLaTeX::Lex(unsigned int startPos, int length, int initStyle 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); - int lengthDoc = startPos + length; + Sci_Position lengthDoc = startPos + length; - for (int i = startPos; i < lengthDoc; i++) { + for (Sci_Position i = startPos; i < lengthDoc; i++) { char ch = chNext; chNext = styler.SafeGetCharAt(i + 1); @@ -207,7 +207,7 @@ void SCI_METHOD LexerLaTeX::Lex(unsigned int startPos, int length, int initStyle 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(unsigned int startPos, int length, int initStyle state = SCE_L_COMMENT; break; } - break; + break; // These 3 will never be reached. case SCE_L_ERROR: case SCE_L_SPECIAL: @@ -325,7 +325,7 @@ void SCI_METHOD LexerLaTeX::Lex(unsigned int startPos, int length, int initStyle case '\\' : styler.ColourTo(i - 1, state); if (latexIsLetter(chNext)) { - int match = i + 3; + Sci_Position match = i + 3; if (latexLastWordIs(match, styler, "\\end")) { match++; if (latexIsTagValid(match, lengthDoc, styler)) { @@ -367,7 +367,7 @@ void SCI_METHOD LexerLaTeX::Lex(unsigned int startPos, int length, int initStyle case '\\' : styler.ColourTo(i - 1, state); if (latexIsLetter(chNext)) { - int match = i + 3; + Sci_Position match = i + 3; if (latexLastWordIs(match, styler, "\\end")) { match++; if (latexIsTagValid(match, lengthDoc, styler)) { @@ -400,7 +400,7 @@ void SCI_METHOD LexerLaTeX::Lex(unsigned int startPos, int length, int initStyle 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; @@ -418,7 +418,7 @@ void SCI_METHOD LexerLaTeX::Lex(unsigned int startPos, int length, int initStyle break; case SCE_L_COMMENT2 : if (ch == '\\') { - int match = i + 3; + Sci_Position match = i + 3; if (latexLastWordIs(match, styler, "\\end")) { match++; if (latexIsTagValid(match, lengthDoc, styler)) { @@ -432,7 +432,7 @@ void SCI_METHOD LexerLaTeX::Lex(unsigned int startPos, int length, int initStyle break; case SCE_L_VERBATIM : if (ch == '\\') { - int match = i + 3; + Sci_Position match = i + 3; if (latexLastWordIs(match, styler, "\\end")) { match++; if (latexIsTagValid(match, lengthDoc, styler)) { @@ -470,23 +470,24 @@ static int latexFoldSaveToInt(const latexFoldSave &save) { // Change folding state while processing a line // Return the level before the first relevant command -void SCI_METHOD LexerLaTeX::Fold(unsigned int startPos, int length, int, IDocument *pAccess) { +void SCI_METHOD LexerLaTeX::Fold(Sci_PositionU startPos, Sci_Position length, int, IDocument *pAccess) { const char *structWords[7] = {"part", "chapter", "section", "subsection", "subsubsection", "paragraph", "subparagraph"}; Accessor styler(pAccess, &props); - unsigned int endPos = startPos + length; - int curLine = styler.GetLine(startPos); + Sci_PositionU endPos = startPos + length; + Sci_Position curLine = styler.GetLine(startPos); latexFoldSave save; getSave(curLine - 1, save); do { char ch, buf[16]; - int i, j, lev = -1; + Sci_Position i, j; + int lev = -1; bool needFold = false; - for (i = static_cast(startPos); i < static_cast(endPos); ++i) { + for (i = static_cast(startPos); i < static_cast(endPos); ++i) { ch = styler.SafeGetCharAt(i); if (ch == '\r' || ch == '\n') break; if (ch != '\\' || styler.StyleAt(i) != SCE_L_COMMAND) continue; - for (j = 0; j < 15 && i + 1 < static_cast(endPos); ++j, ++i) { + for (j = 0; j < 15 && i + 1 < static_cast(endPos); ++j, ++i) { buf[j] = styler.SafeGetCharAt(i + 1); if (!latexIsLetter(buf[j])) break; } @@ -522,7 +523,7 @@ void SCI_METHOD LexerLaTeX::Fold(unsigned int startPos, int length, int, IDocume setSave(curLine, save); ++curLine; startPos = styler.LineStart(curLine); - if (static_cast(startPos) == styler.Length()) { + if (static_cast(startPos) == styler.Length()) { lev = latexFoldSaveToInt(save); styler.SetLevel(curLine, lev); setSave(curLine, save); diff --git a/src/stc/scintilla/lexers/LexLisp.cxx b/src/stc/scintilla/lexers/LexLisp.cxx index 8dd6bd9c43..8d81eae2e2 100644 --- a/src/stc/scintilla/lexers/LexLisp.cxx +++ b/src/stc/scintilla/lexers/LexLisp.cxx @@ -46,10 +46,10 @@ static inline bool isLispwordstart(char ch) { } -static void classifyWordLisp(unsigned int start, unsigned int end, WordList &keywords, WordList &keywords_kw, Accessor &styler) { +static void classifyWordLisp(Sci_PositionU start, Sci_PositionU end, WordList &keywords, WordList &keywords_kw, Accessor &styler) { assert(end >= start); char s[100]; - unsigned int i; + Sci_PositionU i; bool digit_flag = true; for (i = 0; (i < end - start + 1) && (i < 99); i++) { s[i] = styler[start + i]; @@ -74,7 +74,7 @@ static void classifyWordLisp(unsigned int start, unsigned int end, WordList &key } -static void ColouriseLispDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[], +static void ColouriseLispDoc(Sci_PositionU startPos, Sci_Position length, int initStyle, WordList *keywordlists[], Accessor &styler) { WordList &keywords = *keywordlists[0]; @@ -84,9 +84,9 @@ static void ColouriseLispDoc(unsigned int startPos, int length, int initStyle, W int state = initStyle, radix = -1; char chNext = styler[startPos]; - unsigned int lengthDoc = startPos + length; + Sci_PositionU lengthDoc = startPos + length; styler.StartSegment(startPos); - for (unsigned int i = startPos; i < lengthDoc; i++) { + for (Sci_PositionU i = startPos; i < lengthDoc; i++) { char ch = chNext; chNext = styler.SafeGetCharAt(i + 1); @@ -233,16 +233,16 @@ static void ColouriseLispDoc(unsigned int startPos, int length, int initStyle, W styler.ColourTo(lengthDoc - 1, state); } -static void FoldLispDoc(unsigned int startPos, int length, int /* initStyle */, WordList *[], +static void FoldLispDoc(Sci_PositionU startPos, Sci_Position length, int /* initStyle */, WordList *[], Accessor &styler) { - unsigned int lengthDoc = startPos + length; + Sci_PositionU lengthDoc = startPos + length; int visibleChars = 0; - int lineCurrent = styler.GetLine(startPos); + Sci_Position lineCurrent = styler.GetLine(startPos); int levelPrev = styler.LevelAt(lineCurrent) & SC_FOLDLEVELNUMBERMASK; int levelCurrent = levelPrev; char chNext = styler[startPos]; int styleNext = styler.StyleAt(startPos); - for (unsigned int i = startPos; i < lengthDoc; i++) { + for (Sci_PositionU i = startPos; i < lengthDoc; i++) { char ch = chNext; chNext = styler.SafeGetCharAt(i + 1); int style = styleNext; diff --git a/src/stc/scintilla/lexers/LexLout.cxx b/src/stc/scintilla/lexers/LexLout.cxx index 83eb97ec89..39709827d9 100644 --- a/src/stc/scintilla/lexers/LexLout.cxx +++ b/src/stc/scintilla/lexers/LexLout.cxx @@ -40,7 +40,7 @@ static inline bool IsAnOther(const int ch) { ch == ']' || ch == '^' || ch == '`' || ch == '|' || ch == '~'); } -static void ColouriseLoutDoc(unsigned int startPos, int length, int initStyle, +static void ColouriseLoutDoc(Sci_PositionU startPos, Sci_Position length, int initStyle, WordList *keywordlists[], Accessor &styler) { WordList &keywords = *keywordlists[0]; @@ -140,12 +140,12 @@ static void ColouriseLoutDoc(unsigned int startPos, int length, int initStyle, sc.Complete(); } -static void FoldLoutDoc(unsigned int startPos, int length, int, WordList *[], +static void FoldLoutDoc(Sci_PositionU startPos, Sci_Position length, int, WordList *[], Accessor &styler) { - unsigned int endPos = startPos + length; + Sci_PositionU endPos = startPos + length; int visibleChars = 0; - int lineCurrent = styler.GetLine(startPos); + Sci_Position lineCurrent = styler.GetLine(startPos); int levelPrev = styler.LevelAt(lineCurrent) & SC_FOLDLEVELNUMBERMASK; int levelCurrent = levelPrev; char chNext = styler[startPos]; @@ -153,7 +153,7 @@ static void FoldLoutDoc(unsigned int startPos, int length, int, WordList *[], int styleNext = styler.StyleAt(startPos); char s[10] = ""; - for (unsigned int i = startPos; i < endPos; i++) { + for (Sci_PositionU i = startPos; i < endPos; i++) { char ch = chNext; chNext = styler.SafeGetCharAt(i + 1); int style = styleNext; @@ -162,7 +162,7 @@ static void FoldLoutDoc(unsigned int startPos, int length, int, WordList *[], if (style == SCE_LOUT_WORD) { if (ch == '@') { - for (unsigned int j = 0; j < 8; j++) { + for (Sci_PositionU j = 0; j < 8; j++) { if (!IsAWordChar(styler[i + j])) { break; } diff --git a/src/stc/scintilla/lexers/LexLua.cxx b/src/stc/scintilla/lexers/LexLua.cxx index fd0d70fd4d..1e115ad18c 100644 --- a/src/stc/scintilla/lexers/LexLua.cxx +++ b/src/stc/scintilla/lexers/LexLua.cxx @@ -42,8 +42,8 @@ static int LongDelimCheck(StyleContext &sc) { } static void ColouriseLuaDoc( - unsigned int startPos, - int length, + Sci_PositionU startPos, + Sci_Position length, int initStyle, WordList *keywordlists[], Accessor &styler) { @@ -64,10 +64,10 @@ 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, "\"'\\"); - int currentLine = styler.GetLine(startPos); + Sci_Position currentLine = styler.GetLine(startPos); // Initialize long string [[ ... ]] or block comment --[[ ... ]] nesting level, // if we are inside such a string. Block comment was introduced in Lua 5.0, // blocks with separators [=[ ... ]=] in Lua 5.1. @@ -132,10 +132,10 @@ static void ColouriseLuaDoc( if (sc.state == SCE_LUA_OPERATOR) { if (sc.ch == ':' && sc.chPrev == ':') { // ::