| 24 skipped lines |
| 25 | U | 25 | U | // Added fold.compact support set with fold.compact=1 |
|
| 26 | U | 26 | U | // Changed folding inside of #cs-#ce. Default is no keyword folding inside comment blocks when fold.comment=1 |
|
| 27 | U | 27 | U | // it will now only happen when fold.comment=2. |
|
| 28 | C | // | | 28 | C | // Sep 5, 2004 - Added logic to handle colourizing words on the last line. |
| | | 29 | C | // Typed Characters now show as "default" till they match any table. |
| | | 30 | C | // Oct 10, 2004 - Added logic to show Comments in "Special" directives. |
| | | 31 | C | // Nov 1, 2004 - Added better testing for Numbers supporting x and e notation. |
| | | 32 | C | // Nov 28, 2004 - Added logic to handle continuation lines for syntax highlighting. |
| | | 33 | C | // Jan 10, 2005 - Added Abbreviations Keyword used for expansion |
| | | 34 | C | // Mar 24, 2005 - Updated Abbreviations Keywords to fix when followed by Operator. |
| | | 35 | C | // Apr 18, 2005 - Updated #CE/#Comment-End logic to take a linecomment ";" into account |
| | | 36 | C | // - Added folding support for With...EndWith |
| | | 37 | C | // - Added support for a DOT in variable names |
| | | 38 | C | // - Fixed Underscore in CommentBlock |
| | | 39 | C | // May 23, 2005 - Fixed the SentKey lexing in case of a missing } |
| | | 40 | C | // Aug 11, 2005 - Fixed possible bug with s_save length > 100. |
| | | 41 | C | // Aug 23, 2005 - Added Switch/endswitch support to the folding logic. |
| | | 42 | C | // |
| 29 | U | 43 | U | // Copyright for Scintilla: 1998-2001 by Neil Hodgson <neilh@scintilla.org> |
|
| 30 | U | 44 | U | // The License.txt file describes the conditions under which this software may be distributed. |
|
| 31 | U | 45 | U | // Scintilla source code edit control |
|
| 24 skipped lines |
|
| 57 | U | 71 | U | static inline bool IsAWordStart(const int ch) |
|
|
| 59 | C | return (ch < 0x80) && (isalnum(ch) || ch == '_' || ch == '@' || ch == '#' || ch == '$'); | | 73 | C | return (ch < 0x80) && (isalnum(ch) || ch == '_' || ch == '@' || ch == '#' || ch == '$' || ch == '.'); |
|
|
| 62 | U | 76 | U | static inline bool IsAOperator(char ch) { |
|
| 25 skipped lines |
| 88 | U | 102 | U | // split the portion of the sendkey in the part before and after the spaces |
|
| 89 | U | 103 | U | while ( ( (cTemp = szLine[nPos]) != '\0')) |
|
|
| | | 105 | C | // skip leading Ctrl/Shift/ALt state |
| | | 106 | C | if ((cTemp == '#' || cTemp == '!' || cTemp == '^') && (szLine[nPos+1] == '{') ) |
| | | 107 | C | { |
| | | 108 | C | } |
| 91 | C | if ((cTemp == ' ') && (nFlag == 0) ) // get the stuff till first space | | 109 | C | else if ((cTemp == ' ') && (nFlag == 0) ) // get the stuff till first space |
|
|
| 94 | U | 112 | U | // Add } to the end of the first bit for table lookup later. |
|
| 37 skipped lines |
|
| 133 | U | 151 | U | } // GetSendKey() |
|
|
| | | 153 | A | // |
| | | 154 | A | // Routine to check the last "none comment" character on a line to see if its a continuation |
| | | 155 | A | // |
| | | 156 | A | static bool IsContinuationLine(unsigned int szLine, Accessor &styler) |
| | | 157 | A | { |
| 18 skipped lines |
| | | 176 | A | return false; |
| | | 177 | A | } // IsContinuationLine() |
| | | 178 | A | |
| | | 179 | A | // |
| | | 180 | A | // syntax highlighting logic |
| 135 | U | 181 | U | static void ColouriseAU3Doc(unsigned int startPos, |
|
| 136 | U | 182 | U | int length, int initStyle, |
|
| 137 | U | 183 | U | WordList *keywordlists[], |
|
| 5 skipped lines |
| 143 | U | 189 | U | WordList &keywords4 = *keywordlists[3]; |
|
| 144 | U | 190 | U | WordList &keywords5 = *keywordlists[4]; |
|
| 145 | U | 191 | U | WordList &keywords6 = *keywordlists[5]; |
|
| | | 192 | A | WordList &keywords7 = *keywordlists[6]; |
| | | 193 | A | // find the first previous line without continuation character at the end |
| | | 194 | A | int lineCurrent = styler.GetLine(startPos); |
| | | 195 | A | int s_startPos = startPos; |
| | | 196 | A | // When not inside a Block comment: find First line without _ |
| 5 skipped lines |
| | | 202 | A | initStyle = 0; // reset the start style to 0 |
| | | 203 | A | } |
| | | 204 | A | } |
| | | 205 | A | // Set the new length to include it from the start and set the start position |
| | | 206 | A | length = length + s_startPos - startPos; // correct the total length to process |
| 146 | U | 207 | U | styler.StartAt(startPos); |
|
| 147 | C | | | 208 | C | |
| 148 | U | 209 | U | StyleContext sc(startPos, length, initStyle, styler); |
|
| 149 | U | 210 | U | char si; // string indicator "=1 '=2 |
|
| | | 211 | C | char ni; // Numeric indicator error=9 normal=0 normal+dec=1 hex=2 Enot=3 |
| | | 212 | C | char ci; // comment indicator 0=not linecomment(;) |
| | | 213 | C | char s_save[100]; |
| 150 | C | si=0; | | 214 | C | si=0; |
| | | 215 | C | ni=0; |
| | | 216 | C | ci=0; |
|
| 152 | U | 218 | U | for (; sc.More(); sc.Forward()) { |
|
|
| 154 | U | 220 | U | sc.GetCurrentLowered(s, sizeof(s)); |
|
| | | 221 | A | // ********************************************** |
| | | 222 | A | // save the total current word for eof processing |
| | | 223 | A | if (IsAWordChar(sc.ch) || sc.ch == '}') |
| | | 224 | A | { |
| | | 225 | A | strcpy(s_save,s); |
| 3 skipped lines |
| | | 229 | A | s_save[tp+1] = '\0'; |
| | | 230 | A | } |
| | | 231 | A | } |
| | | 232 | A | // ********************************************** |
| | | 233 | A | // |
| 155 | U | 234 | U | switch (sc.state) |
|
|
| 157 | U | 236 | U | case SCE_AU3_COMMENTBLOCK: |
|
|
| | | 238 | C | //Reset at line end |
| | | 239 | C | if (sc.atLineEnd) { |
| | | 240 | C | ci=0; |
| | | 241 | C | sc.SetState(SCE_AU3_COMMENTBLOCK); |
| | | 242 | C | } |
| | | 243 | C | //skip rest of line when a ; is encountered |
| | | 244 | C | if (sc.chPrev == ';') { |
| | | 245 | C | ci=2; |
| | | 246 | C | sc.SetState(SCE_AU3_COMMENTBLOCK); |
| | | 247 | C | } |
| | | 248 | C | // skip rest of the line |
| | | 249 | C | if (ci==2) |
| | | 250 | C | break; |
| | | 251 | C | // check when first character is detected on the line |
| | | 252 | C | if (ci==0) { |
| | | 253 | C | if (IsAWordStart(static_cast<char>(sc.ch)) || IsAOperator(static_cast<char>(sc.ch))) { |
| | | 254 | C | ci=1; |
| | | 255 | C | sc.SetState(SCE_AU3_COMMENTBLOCK); |
| | | 256 | C | } |
| | | 257 | C | break; |
| | | 258 | C | } |
| 159 | C | if (!(IsAWordChar(sc.ch) || (sc.ch == '-' && strcmp(s, "#comments") == 0))) | | 259 | C | if (!(IsAWordChar(sc.ch) || (sc.ch == '-' && strcmp(s, "#comments") == 0))) { |
| 160 | C | { | | |
| 161 | U | 260 | U | if ((strcmp(s, "#ce")== 0 || strcmp(s, "#comments-end")== 0)) |
|
| 162 | C | {sc.SetState(SCE_AU3_COMMENT);} // set to comment line for the rest of the line | | 261 | C | sc.SetState(SCE_AU3_COMMENT); // set to comment line for the rest of the line |
|
| 164 | C | {sc.SetState(SCE_AU3_COMMENTBLOCK);} | | 263 | C | ci=2; // line doesn't begin with #CE so skip the rest of the line |
|
|
|
| 4 skipped lines |
|
| 173 | U | 272 | U | case SCE_AU3_OPERATOR: |
|
|
| | | 274 | C | // check if its a COMobject |
| | | 275 | C | if (sc.chPrev == '.' && IsAWordChar(sc.ch)) { |
| | | 276 | C | sc.SetState(SCE_AU3_COMOBJ); |
| | | 277 | C | } |
| | | 278 | C | else { |
| 175 | C | sc.SetState(SCE_AU3_DEFAULT); | | 279 | C | sc.SetState(SCE_AU3_DEFAULT); |
| | | 280 | C | } |
|
|
| 178 | U | 283 | U | case SCE_AU3_SPECIAL: |
|
|
| | | 285 | C | if (sc.ch == ';') {sc.SetState(SCE_AU3_COMMENT);} |
| 180 | C | if (sc.atLineEnd) {sc.SetState(SCE_AU3_DEFAULT);} | | 286 | C | if (sc.atLineEnd) {sc.SetState(SCE_AU3_DEFAULT);} |
|
|
| 183 | U | 289 | U | case SCE_AU3_KEYWORD: |
|
| 31 skipped lines |
| 215 | U | 321 | U | sc.ChangeState(SCE_AU3_SPECIAL); |
|
| 216 | U | 322 | U | sc.SetState(SCE_AU3_SPECIAL); |
|
|
| | | 324 | A | else if ((keywords7.InList(s)) && (!IsAOperator(static_cast<char>(sc.ch)))) { |
| | | 325 | A | sc.ChangeState(SCE_AU3_EXPAND); |
| | | 326 | A | sc.SetState(SCE_AU3_DEFAULT); |
| | | 327 | A | } |
| 218 | U | 328 | U | else if (strcmp(s, "_") == 0) { |
|
| 219 | U | 329 | U | sc.ChangeState(SCE_AU3_OPERATOR); |
|
| 220 | U | 330 | U | sc.SetState(SCE_AU3_DEFAULT); |
|
| 4 skipped lines |
|
|
|
| | | 338 | C | if (sc.atLineEnd) { |
| 228 | C | if (sc.atLineEnd) {sc.SetState(SCE_AU3_DEFAULT);} | | 339 | C | sc.SetState(SCE_AU3_DEFAULT);} |
|
|
| 231 | C | case SCE_AU3_NUMBER: | | 342 | C | case SCE_AU3_NUMBER: |
|
| | | 344 | C | // Numeric indicator error=9 normal=0 normal+dec=1 hex=2 E-not=3 |
| | | 345 | C | // |
| | | 346 | C | // test for Hex notation |
| | | 347 | C | if (strcmp(s, "0") == 0 && (sc.ch == 'x' || sc.ch == 'X') && ni == 0) |
| | | 348 | C | { |
| | | 349 | C | ni = 2; |
| | | 350 | C | break; |
| | | 351 | C | } |
| | | 352 | C | // test for E notation |
| | | 353 | C | if (IsADigit(sc.chPrev) && (sc.ch == 'e' || sc.ch == 'E') && ni <= 1) |
| 32 skipped lines |
| | | 386 | C | } |
| | | 387 | C | break; |
| | | 388 | C | } |
| | | 389 | C | case SCE_AU3_VARIABLE: |
| | | 390 | C | { |
| | | 391 | C | // Check if its a COMObject |
| | | 392 | C | if (sc.ch == '.' && !IsADigit(sc.chNext)) { |
| | | 393 | C | sc.SetState(SCE_AU3_OPERATOR); |
| | | 394 | C | } |
| | | 395 | C | else if (!IsAWordChar(sc.ch)) { |
| 233 | C | if (!IsAWordChar(sc.ch)) {sc.SetState(SCE_AU3_DEFAULT);} | | 396 | C | sc.SetState(SCE_AU3_DEFAULT); |
| | | 397 | C | } |
| 234 | C | break; | | 398 | C | break; |
|
| 236 | C | case SCE_AU3_VARIABLE: | | 400 | C | case SCE_AU3_COMOBJ: |
| 237 | C | { | | 401 | C | { |
| | | 402 | C | if (!(IsAWordChar(sc.ch))) { |
| 238 | C | if (!IsAWordChar(sc.ch)) {sc.SetState(SCE_AU3_DEFAULT);} | | 403 | C | sc.SetState(SCE_AU3_DEFAULT); |
| | | 404 | C | } |
| 239 | C | break; | | 405 | C | break; |
|
| 241 | U | 407 | U | case SCE_AU3_STRING: |
|
|
| 3 skipped lines |
|
| 247 | U | 413 | U | sc.ForwardSetState(SCE_AU3_DEFAULT); |
|
|
| | | 415 | C | if (sc.atLineEnd) |
| | | 416 | C | { |
| | | 417 | C | // at line end and not found a continuation char then reset to default |
| | | 418 | C | int lineCurrent = styler.GetLine(sc.currentPos); |
| | | 419 | C | if (!IsContinuationLine(lineCurrent,styler)) |
| | | 420 | C | { |
| 249 | C | if (sc.atLineEnd) {sc.SetState(SCE_AU3_DEFAULT);} | | 421 | C | sc.SetState(SCE_AU3_DEFAULT); |
| | | 422 | C | } |
| | | 423 | C | } |
| 250 | U | 424 | U | // find Sendkeys in a STRING |
|
| 251 | U | 425 | U | if (sc.ch == '{') {sc.SetState(SCE_AU3_SENT);} |
|
| 252 | U | 426 | U | if (sc.ch == '+' && sc.chNext == '{') {sc.SetState(SCE_AU3_SENT);} |
|
| 35 skipped lines |
| 288 | U | 462 | U | // check if next portion is again a sendkey |
|
| 289 | U | 463 | U | if (sc.atLineEnd) |
|
|
| | | 465 | A | sc.ChangeState(SCE_AU3_STRING); |
| 291 | U | 466 | U | sc.SetState(SCE_AU3_DEFAULT); |
|
| 292 | U | 467 | U | si = 0; // reset string indicator |
|
|
| 294 | C | if (sc.ch == '{' && sc.chPrev != '{') {sc.SetState(SCE_AU3_SENT);} | | 469 | C | //if (sc.ch == '{' && sc.chPrev != '{') {sc.SetState(SCE_AU3_SENT);} |
| 295 | U | 470 | U | if (sc.ch == '+' && sc.chNext == '{') {sc.SetState(SCE_AU3_SENT);} |
|
| 296 | U | 471 | U | if (sc.ch == '!' && sc.chNext == '{') {sc.SetState(SCE_AU3_SENT);} |
|
| 297 | U | 472 | U | if (sc.ch == '^' && sc.chNext == '{') {sc.SetState(SCE_AU3_SENT);} |
|
| 16 skipped lines |
| 314 | U | 489 | U | if (sc.ch == ';') {sc.SetState(SCE_AU3_COMMENT);} |
|
| 315 | U | 490 | U | else if (sc.ch == '#') {sc.SetState(SCE_AU3_KEYWORD);} |
|
| 316 | U | 491 | U | else if (sc.ch == '$') {sc.SetState(SCE_AU3_VARIABLE);} |
|
| | | 492 | A | else if (sc.ch == '.' && !IsADigit(sc.chNext)) {sc.SetState(SCE_AU3_OPERATOR);} |
| 317 | U | 493 | U | else if (sc.ch == '@') {sc.SetState(SCE_AU3_KEYWORD);} |
|
| 318 | U | 494 | U | else if (sc.ch == '<' && si==3) {sc.SetState(SCE_AU3_STRING);} // string after #include |
|
| 319 | U | 495 | U | else if (sc.ch == '\"') { |
|
| 2 skipped lines |
| 322 | U | 498 | U | else if (sc.ch == '\'') { |
|
| 323 | U | 499 | U | sc.SetState(SCE_AU3_STRING); |
|
|
| 325 | C | else if (IsADigit(sc.ch) || (sc.ch == '.' && IsADigit(sc.chNext))) {sc.SetState(SCE_AU3_NUMBER);} | | 501 | C | else if (IsADigit(sc.ch) || (sc.ch == '.' && IsADigit(sc.chNext))) |
| | | 502 | C | { |
| | | 503 | C | sc.SetState(SCE_AU3_NUMBER); |
| | | 504 | C | ni = 0; |
| | | 505 | C | } |
| 326 | U | 506 | U | else if (IsAWordStart(sc.ch)) {sc.SetState(SCE_AU3_KEYWORD);} |
|
| 327 | U | 507 | U | else if (IsAOperator(static_cast<char>(sc.ch))) {sc.SetState(SCE_AU3_OPERATOR);} |
|
| 328 | U | 508 | U | else if (sc.atLineEnd) {sc.SetState(SCE_AU3_DEFAULT);} |
|
|
| 330 | U | 510 | U | } //for (; sc.More(); sc.Forward()) |
|
| | | 511 | C | |
| | | 512 | C | //************************************* |
| | | 513 | C | // Colourize the last word correctly |
| | | 514 | C | //************************************* |
| | | 515 | C | if (sc.state == SCE_AU3_KEYWORD) |
| | | 516 | C | { |
| | | 517 | C | if (strcmp(s_save, "#cs")== 0 || strcmp(s_save, "#comments-start")== 0 ) |
| | | 518 | C | { |
| | | 519 | C | sc.ChangeState(SCE_AU3_COMMENTBLOCK); |
| | | 520 | C | sc.SetState(SCE_AU3_COMMENTBLOCK); |
| 57 skipped lines |
| | | 578 | C | sc.SetState(SCE_AU3_STRING); |
| | | 579 | C | } |
| | | 580 | C | // check if next portion is again a sendkey |
| | | 581 | C | if (sc.atLineEnd) |
| | | 582 | C | { |
| | | 583 | C | sc.ChangeState(SCE_AU3_STRING); |
| | | 584 | C | sc.SetState(SCE_AU3_DEFAULT); |
| | | 585 | C | } |
| | | 586 | C | } |
| | | 587 | C | //************************************* |
| 331 | C | sc.Complete(); | | 588 | C | sc.Complete(); |
|
|
|
| 17 skipped lines |
|
| 353 | U | 610 | U | } // GetStyleFirstWord() |
|
|
| 355 | R | // | | |
| 356 | R | // Routine to check the last "none comment" character on a line to see if its a continuation | | |
| 357 | R | // | | |
| 358 | R | static bool IsContinuationLine(unsigned int szLine, Accessor &styler) | | |
| 359 | R | { | | |
| 16 skipped lines |
| 376 | R | nePos--; // skip to next char | | |
| 377 | R | } // End While | | |
| 378 | R | return false; | | |
| 379 | R | } // IsContinuationLine() | | |
| 380 | R | | | |
|
|
| 383 | U | 614 | U | static void FoldAU3Doc(unsigned int startPos, int length, int, WordList *[], Accessor &styler) |
|
| 112 skipped lines |
| 496 | U | 727 | U | // create new fold for these words |
|
| 497 | U | 728 | U | if (strcmp(szKeyword,"do") == 0 || strcmp(szKeyword,"for") == 0 || |
|
| 498 | U | 729 | U | strcmp(szKeyword,"func") == 0 || strcmp(szKeyword,"while") == 0|| |
|
| 499 | C | strcmp(szKeyword,"#region") == 0 ) { | | 730 | C | strcmp(szKeyword,"with") == 0 || strcmp(szKeyword,"#region") == 0 ) { |
|
|
| 502 | C | // create double Fold for select because Case will subtract one of the current level | | 733 | C | // create double Fold for select&switch because Case will subtract one of the current level |
| 503 | C | if (strcmp(szKeyword,"select") == 0) { | | 734 | C | if (strcmp(szKeyword,"select") == 0 || strcmp(szKeyword,"switch") == 0) { |
|
|
|
| 507 | U | 738 | U | // end the fold for these words before the current line |
|
| 508 | U | 739 | U | if (strcmp(szKeyword,"endfunc") == 0 || strcmp(szKeyword,"endif") == 0 || |
|
| 509 | U | 740 | U | strcmp(szKeyword,"next") == 0 || strcmp(szKeyword,"until") == 0 || |
|
| 510 | C | strcmp(szKeyword,"wend") == 0){ | | 741 | C | strcmp(szKeyword,"endwith") == 0 ||strcmp(szKeyword,"wend") == 0){ |
|
|
|
| 3 skipped lines |
|
|
| 519 | U | 750 | U | // end the double fold for this word before the current line |
|
| 520 | C | if (strcmp(szKeyword,"endselect") == 0 ) { | | 751 | C | if (strcmp(szKeyword,"endselect") == 0 || strcmp(szKeyword,"endswitch") == 0 ) { |
|
|
|
| 85 skipped lines |
| 609 | U | 840 | U | "#autoit Sent keys", |
|
| 610 | U | 841 | U | "#autoit Pre-processors", |
|
| 611 | U | 842 | U | "#autoit Special", |
|
| | | 843 | A | "#autoit Expand", |
|
|
| 614 | U | 846 | U | LexerModule lmAU3(SCLEX_AU3, ColouriseAU3Doc, "au3", FoldAU3Doc , AU3WordLists); |
|
| 1 skipped line |