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