--- include/SciLexer.h Sun Apr 04 11:40:56 1971 +++ include/SciLexer.h Sun Apr 04 11:40:56 1971 @@ -894,6 +894,8 @@ #define SCE_AU3_EXPAND 13 #define SCE_AU3_COMOBJ 14 #define SCE_AU3_UDF 15 +// SciTE4Autoit3 => Added by Jos +#define SCE_AU3_USERUDF 16 #define SCE_APDL_DEFAULT 0 #define SCE_APDL_COMMENT 1 #define SCE_APDL_COMMENTBLOCK 2 --- lexers/LexAU3.cxx Sun Apr 04 11:42:16 1971 +++ lexers/LexAU3.cxx Sun Apr 04 11:42:16 1971 @@ -1,6 +1,6 @@ // Scintilla source code edit control // @file LexAU3.cxx -// Lexer for AutoIt3 http://www.hiddensoft.com/autoit3 +// Lexer for AutoIt3 http://www.autoitscript.com/autoit3 // by Jos van der Zande, jvdzande@yahoo.com // // Changes: @@ -45,6 +45,15 @@ // Mar 9, 2007 - Fixed bug with + following a String getting the wrong Color. // Jun 20, 2007 - Fixed Commentblock issue when LF's are used as EOL. // Jul 26, 2007 - Fixed #endregion undetected bug. +// Jun 14, 2008 - Fixed Nested commentblock detection. +// Aug 14, 2008 - Fixed stackcorruption leading to a crash. +// Nov 20, 2008 - Fixed end comment block detection problem and Folding comment block problem. +// - Fixed Folding for #comments-start - #comments-end blocks. +// Mar 27, 2009 - Added Extra Lexer user UDFs table +// Jun 10, 2009 - Fixed folding checking now for Space+Underscore when checking for continuation character +// Nov 29, 2009 - Fixed folding issue when continuation line contained comments at the end of the line. +// Feb 16, 2011 - Fixed E notation lexing to include more notation options. +// Jul 11, 2011 - Fixed E notation lexing to avoid recognising Comobj variables with ".E". // // Copyright for Scintilla: 1998-2001 by Neil Hodgson // The License.txt file describes the conditions under which this software may be distributed. @@ -168,7 +177,7 @@ } // GetSendKey() // -// Routine to check the last "none comment" character on a line to see if its a continuation +// Routine to check the last "none comment" characters on a line to see if its a continuation line // static bool IsContinuationLine(unsigned int szLine, Accessor &styler) { @@ -177,18 +186,18 @@ //int stylech = styler.StyleAt(nsPos); while (nsPos < nePos) { - //stylech = styler.StyleAt(nePos); - int stylech = styler.StyleAt(nsPos); + // Find the last none comment character. When its " _" then return true + int stylech = styler.StyleAt(nePos); if (!(stylech == SCE_AU3_COMMENT)) { char ch = styler.SafeGetCharAt(nePos); if (!isspacechar(ch)) { - if (ch == '_') + if (ch == '_' && styler.SafeGetCharAt(nePos-1) == ' ') return true; else return false; } } - nePos--; // skip to next char + nePos--; // skip to previous char } // End While return false; } // IsContinuationLine() @@ -208,16 +217,21 @@ WordList &keywords6 = *keywordlists[5]; WordList &keywords7 = *keywordlists[6]; WordList &keywords8 = *keywordlists[7]; + WordList &keywords9 = *keywordlists[8]; // find the first previous line without continuation character at the end int lineCurrent = styler.GetLine(startPos); int s_startPos = startPos; - // When not inside a Block comment: find First line without _ + // When not inside a Block comment: find first line without continuation character "_" if (!(initStyle==SCE_AU3_COMMENTBLOCK)) { while ((lineCurrent > 0 && IsContinuationLine(lineCurrent,styler)) || (lineCurrent > 1 && IsContinuationLine(lineCurrent-1,styler))) { lineCurrent--; startPos = styler.LineStart(lineCurrent); // get start position - initStyle = 0; // reset the start style to 0 + // reset the initStyle to proper style of the new line for Commentblocks + if (styler.StyleAt(startPos) == SCE_AU3_COMMENTBLOCK) + initStyle=SCE_AU3_COMMENTBLOCK; + else + initStyle=0; } } // Set the new length to include it from the start and set the start position @@ -232,9 +246,18 @@ si=0; ni=0; ci=0; + int nestLevel = 0; + int sepCount = 0; + // Set Comment nesting level when inside commentblock + if (initStyle == SCE_AU3_COMMENTBLOCK) { + int lineState = styler.GetLineState(lineCurrent - 1); + nestLevel = lineState >> 8; + sepCount = lineState & 0xFF; + } //$$$ for (; sc.More(); sc.Forward()) { char s[100]; + lineCurrent = styler.GetLine(sc.currentPos); sc.GetCurrentLowered(s, sizeof(s)); // ********************************************** // save the total current word for eof processing @@ -253,13 +276,16 @@ { case SCE_AU3_COMMENTBLOCK: { - //Reset at line end + //Set the level or Reset to default at line end if (sc.atLineEnd) { ci=0; - if (strcmp(s, "#ce")== 0 || strcmp(s, "#comments-end")== 0) { - if (sc.atLineEnd) + // reset to default when #CE or #comments-end was found and not nested. + if (nestLevel==0){ sc.SetState(SCE_AU3_DEFAULT); - else + styler.SetLineState(lineCurrent, 0); + } + else { + styler.SetLineState(lineCurrent, (nestLevel << 8) | sepCount); sc.SetState(SCE_AU3_COMMENTBLOCK); } break; @@ -267,12 +293,9 @@ //skip rest of line when a ; is encountered if (sc.chPrev == ';') { ci=2; - sc.SetState(SCE_AU3_COMMENTBLOCK); + //sc.SetState(SCE_AU3_COMMENTBLOCK); } - // skip rest of the line - if (ci==2) - break; - // check when first character is detected on the line + // check when first character is detected on the line and reset the S buffer by setting the state. if (ci==0) { if (IsAWordStart(static_cast(sc.ch)) || IsAOperator(static_cast(sc.ch))) { ci=1; @@ -280,11 +303,13 @@ } break; } - if (!(IsAWordChar(sc.ch) || (sc.ch == '-' && strcmp(s, "#comments") == 0))) { - if ((strcmp(s, "#ce")== 0 || strcmp(s, "#comments-end")== 0)) - sc.SetState(SCE_AU3_COMMENT); // set to comment line for the rest of the line - else - ci=2; // line doesn't begin with #CE so skip the rest of the line + // Process Nested commentblocks and "End of commentblock" statements + if ((strcmp(s, "#cs")== 0 || strcmp(s, "#comments-start")== 0)) { + nestLevel++; + } + if ((strcmp(s, "#ce")== 0 || strcmp(s, "#comments-end")== 0)) { + nestLevel--; + // When on toplevel comment block set next line to Default. } break; } @@ -318,6 +343,7 @@ { if (strcmp(s, "#cs")== 0 || strcmp(s, "#comments-start")== 0 ) { + nestLevel++; sc.ChangeState(SCE_AU3_COMMENTBLOCK); sc.SetState(SCE_AU3_COMMENTBLOCK); break; @@ -354,6 +380,10 @@ sc.ChangeState(SCE_AU3_UDF); sc.SetState(SCE_AU3_DEFAULT); } + else if (keywords9.InList(s)) { + sc.ChangeState(SCE_AU3_USERUDF); + sc.SetState(SCE_AU3_DEFAULT); + } else if (strcmp(s, "_") == 0) { sc.ChangeState(SCE_AU3_OPERATOR); sc.SetState(SCE_AU3_DEFAULT); @@ -379,11 +409,16 @@ break; } // test for E notation - if (IsADigit(sc.chPrev) && (sc.ch == 'e' || sc.ch == 'E') && ni <= 1) + if ((IsADigit(sc.chPrev) || sc.chPrev == '.') && (sc.ch == 'e' || sc.ch == 'E') && ni <= 1) { ni = 3; break; } + // test for + or - in E notation right behind the E. + if ((sc.chPrev == 'e' || sc.chPrev == 'E') && (sc.ch == '+'|| sc.ch == '-') && ni == 3) + { + break; + } // Allow Hex characters inside hex numeric strings if ((ni == 2) && (sc.ch == 'a' || sc.ch == 'b' || sc.ch == 'c' || sc.ch == 'd' || sc.ch == 'e' || sc.ch == 'f' || @@ -547,7 +582,6 @@ if (sc.ch == ';') {sc.SetState(SCE_AU3_COMMENT);} else if (sc.ch == '#') {sc.SetState(SCE_AU3_KEYWORD);} else if (sc.ch == '$') {sc.SetState(SCE_AU3_VARIABLE);} - else if (sc.ch == '.' && !IsADigit(sc.chNext)) {sc.SetState(SCE_AU3_OPERATOR);} else if (sc.ch == '@') {sc.SetState(SCE_AU3_KEYWORD);} //else if (sc.ch == '_') {sc.SetState(SCE_AU3_KEYWORD);} else if (sc.ch == '<' && si==3) {sc.SetState(SCE_AU3_STRING);} // string after #include @@ -557,11 +591,19 @@ else if (sc.ch == '\'') { sc.SetState(SCE_AU3_STRING); si = 2; } + // Handle Numbers else if (IsADigit(sc.ch) || (sc.ch == '.' && IsADigit(sc.chNext))) { sc.SetState(SCE_AU3_NUMBER); ni = 0; + } + // Handle E notations + else if (IsADigit(sc.chPrev) && sc.ch == '.' && (sc.chNext == 'e' || sc.chNext == 'E')) + { + sc.SetState(SCE_AU3_NUMBER); + ni = 0; } + else if (sc.ch == '.' && !(IsADigit(sc.chNext))) {sc.SetState(SCE_AU3_OPERATOR);} else if (IsAWordStart(sc.ch)) {sc.SetState(SCE_AU3_KEYWORD);} else if (IsAOperator(static_cast(sc.ch))) {sc.SetState(SCE_AU3_OPERATOR);} else if (sc.atLineEnd) {sc.SetState(SCE_AU3_DEFAULT);} @@ -606,6 +648,10 @@ sc.ChangeState(SCE_AU3_UDF); sc.SetState(SCE_AU3_UDF); } + else if (keywords9.InList(s_save)) { + sc.ChangeState(SCE_AU3_USERUDF); + sc.SetState(SCE_AU3_USERUDF); + } else { sc.ChangeState(SCE_AU3_DEFAULT); sc.SetState(SCE_AU3_DEFAULT); @@ -698,6 +744,8 @@ (lineCurrent > 1 && IsContinuationLine(lineCurrent-1,styler))) { lineCurrent--; startPos = styler.LineStart(lineCurrent); + // Ensure the style is refreshed when changing the line + style = GetStyleFirstWord(lineCurrent,styler); } if (lineCurrent > 0) { stylePrev = GetStyleFirstWord(lineCurrent-1,styler); @@ -705,7 +753,7 @@ // vars for getting first word to check for keywords bool FirstWordStart = false; bool FirstWordEnd = false; - char szKeyword[11]=""; + char szKeyword[20]=""; int szKeywordlen = 0; char szThen[5]=""; int szThenlen = 0; @@ -717,38 +765,59 @@ int levelNext = levelCurrent; // int visibleChars = 0; - char chNext = styler.SafeGetCharAt(startPos); - char chPrev = ' '; + char chPrevSave1 = ' '; // Save of last 2 characters needed to find continuation " _" + char chPrevSave2 = ' '; // Save of last 2 characters needed to find continuation " _" + char chPrev1 = ' '; // current character -1 + char chPrev2 = ' '; // current character -2 + char ch = ' '; // current character + char chNext = styler.SafeGetCharAt(startPos); // Next character // for (int i = startPos; i < endPos; i++) { - char ch = chNext; + chPrev2 = chPrev1; + chPrev1 = ch; + ch = chNext; chNext = styler.SafeGetCharAt(i + 1); if (IsAWordChar(ch)) { visibleChars++; } - // get the syle for the current character neede to check in comment + // get the syle for the current character needed to check in comment int stylech = styler.StyleAt(i); // get first word for the line for indent check max 9 characters if (FirstWordStart && (!(FirstWordEnd))) { if (!IsAWordChar(ch)) { + // check for #comment-start and #comment-end + if (!(IsStreamCommentStyle(stylech) && ch == '-')) { + FirstWordEnd = true; + szKeyword[szKeywordlen] = '\0'; + } + else if ( strcmp(szKeyword, "#comments-start")==0 || strcmp(szKeyword, "#comments-end")==0){ FirstWordEnd = true; szKeyword[szKeywordlen] = '\0'; } else { - if (szKeywordlen < 10) { + if (szKeywordlen < 19) { szKeyword[szKeywordlen++] = static_cast(tolower(ch)); } } } + else { + if (szKeywordlen < 19) { + szKeyword[szKeywordlen++] = static_cast(tolower(ch)); + szKeyword[szKeywordlen] = '\0'; + } + } + } // start the capture of the first word if (!(FirstWordStart)) { + szKeywordlen = 0; if (IsAWordChar(ch) || IsAWordStart(ch) || ch == ';') { FirstWordStart = true; szKeyword[szKeywordlen++] = static_cast(tolower(ch)); + szKeyword[szKeywordlen] = '\0'; } } // only process this logic when not in comment section - if (!(stylech == SCE_AU3_COMMENT)) { + if (!IsStreamCommentStyle(stylech)) { if (ThenFoundLast) { if (IsAWordChar(ch)) { ThenFoundLast = false; @@ -761,7 +830,7 @@ szThen[1] = szThen[2]; szThen[2] = szThen[3]; szThen[3] = static_cast(tolower(ch)); - if (strcmp(szThen,"then") == 0 ) { + if (strcmp(szThen,"then") == 0 && stylech == SCE_AU3_KEYWORD) { ThenFoundLast = true; } } @@ -780,7 +849,7 @@ // ************************** // if a keyword is found on the current line and the line doesn't end with _ (continuation) // and we are not inside a commentblock. - if (szKeywordlen > 0 && (!(chPrev == '_')) && + if (szKeywordlen > 0 && (!(chPrevSave2 == ' ') || !(chPrevSave1 == '_')) && ((!(IsStreamCommentStyle(style)) || foldInComment)) ) { szKeyword[szKeywordlen] = '\0'; // only fold "if" last keyword is "then" (else its a one line if) @@ -841,10 +910,19 @@ // Folding logic for Comment blocks // ********************************* if (foldComment && IsStreamCommentStyle(style)) { - // Start of a comment block - if (!(stylePrev==style) && IsStreamCommentStyle(styleNext) && styleNext==style) { + // Start of a block of single comment lines + if (!(stylePrev==style) && styleNext==SCE_AU3_COMMENT && styleNext==style) { levelNext++; } + // Add level when Comment block starts + else if ((strcmp(szKeyword, "#cs")== 0 || strcmp(szKeyword, "#comments-start")== 0)) { + levelNext++; + } + // Subtract level when Comment block Ends + else if ((strcmp(szKeyword, "#ce")== 0 || strcmp(szKeyword, "#comments-end")== 0)) { + levelNext--; + levelCurrent--; + } // fold till the last line for normal comment lines else if (IsStreamCommentStyle(stylePrev) && !(styleNext == SCE_AU3_COMMENT) @@ -852,13 +930,11 @@ && style == SCE_AU3_COMMENT) { levelNext--; } - // fold till the one but last line for Blockcomment lines - else if (IsStreamCommentStyle(stylePrev) - && !(styleNext == SCE_AU3_COMMENTBLOCK) - && style == SCE_AU3_COMMENTBLOCK) { - levelNext--; - levelCurrent--; - } + // reset Keyword in commentblocks to avoid folding issues. + szKeyword[0] = '\0'; + szKeywordlen = 0; + FirstWordStart = false; + FirstWordEnd = false; } int levelUse = levelCurrent; int lev = levelUse | levelNext << 16; @@ -876,18 +952,23 @@ style = styleNext; levelCurrent = levelNext; visibleChars = 0; - // if the last character is an Underscore then don't reset since the line continues on the next line. - if (!(chPrev == '_')) { + // if the last 2 characters are Space+Underscore then don't reset since the line continues on the next line. + if (!(chPrevSave2 == ' ') || !(chPrevSave1 == '_')) { szKeywordlen = 0; + szKeyword[0] = '\0'; szThenlen = 0; FirstWordStart = false; FirstWordEnd = false; ThenFoundLast = false; } + chPrevSave2 = ' '; + chPrevSave1 = ' '; } - // save the last processed character - if (!isspacechar(ch)) { - chPrev = ch; + // save the last processed character which is none space and not in a comment section. + // This is required to figure out if we are on a Continuation line. (Space+Underscore) + if ((!isspacechar(ch)) && !(stylech == SCE_AU3_COMMENT)) { + chPrevSave2 = chPrev1; + chPrevSave1 = ch; visibleChars++; } } @@ -905,6 +986,7 @@ "#autoit Special", "#autoit Expand", "#autoit UDF", + "#autoit UserUDF", 0 }; LexerModule lmAU3(SCLEX_AU3, ColouriseAU3Doc, "au3", FoldAU3Doc , AU3WordLists); --- lexers/LexOthers.cxx Mon Apr 05 23:53:28 1971 +++ lexers/LexOthers.cxx Mon Apr 05 23:53:28 1971 @@ -1014,12 +1014,14 @@ // Lua 5.1: : :: bool initialTab = (lineBuffer[0] == '\t'); bool initialColonPart = false; +// SciTE4Autoit3 => start Updated by Jos: Allow Quoted filenames to support (x86) in filepath name enum { stInitial, stGccStart, stGccDigit, stGcc, stMsStart, stMsDigit, stMsBracket, stMsVc, stMsDigitComma, stMsDotNet, stCtagsStart, stCtagsStartString, stCtagsStringDollar, stCtags, - stUnrecognized + stUnrecognized,StDoubleQuoted } state = stInitial; +// SciTE4Autoit3 => end Updated by Jos: Allow Quoted filenames to support (x86) in filepath name for (unsigned int i = 0; i < lengthLine; i++) { char ch = lineBuffer[i]; char chNext = ' '; @@ -1042,7 +1044,12 @@ } else if ((ch == '\t') && (!initialTab)) { // May be CTags state = stCtagsStart; - } +// SciTE4Autoit3 => start Updated by Jos: Allow Quoted filenames to support (x86) in filepath name + } else if (ch == '"') { + // Quoted Filenames + state = StDoubleQuoted; +// SciTE4Autoit3 => end Updated by Jos: Allow Quoted filenames to support (x86) in filepath name + } } else if (state == stGccStart) { // : state = Is1To9(ch) ? stGccDigit : stUnrecognized; } else if (state == stGccDigit) { // : @@ -1106,6 +1113,10 @@ } else if ((state == stCtagsStartString) && ((lineBuffer[i] == '$') && (lineBuffer[i + 1] == '/'))) { state = stCtagsStringDollar; break; +// SciTE4Autoit3 => start Updated by Jos: Allow Quoted filenames to support (x86) in filepath name + } else if ((state == StDoubleQuoted) && (ch == '"')) { + state = stInitial; +// SciTE4Autoit3 => end Updated by Jos: Allow Quoted filenames to support (x86) in filepath name } } if (state == stGcc) { --- src/Catalogue.cxx Sun Apr 04 11:40:56 1971 +++ src/Catalogue.cxx Sun Apr 04 11:40:56 1971 @@ -81,6 +81,12 @@ //++Autogenerated -- run src/LexGen.py to regenerate //**\(\tLINK_LEXER(\*);\n\) +//***************************************************************************************************************** +// SciTE4Autoit3 => start Updated by Jos to include only Standard,AutoIt3 and Error lexers in the Lite version of SciTE4AutoIt3 +LINK_LEXER(lmAU3); +LINK_LEXER(lmErrorList); +#ifndef STATIC_BUILD + // LINK_LEXER(lmA68k); LINK_LEXER(lmAbaqus); LINK_LEXER(lmAda); @@ -179,6 +185,10 @@ LINK_LEXER(lmVHDL); LINK_LEXER(lmXML); LINK_LEXER(lmYAML); + // +#endif +// SciTE4Autoit3 => End Updated by Jos to include only Standard,AutoIt3 and Error lexers in the Lite version of SciTE4AutoIt3 +//**************************************************************************************************************** //--Autogenerated -- end of automatically generated section