Changeset View
Changeset View
Standalone View
Standalone View
src/script/data/indentation/cppstyle.js
Show First 20 Lines • Show All 60 Lines • ▼ Show 20 Line(s) | |||||
61 | // '<' and '>' is for templates | 61 | // '<' and '>' is for templates | ||
62 | // '#' is for preprocessor directives | 62 | // '#' is for preprocessor directives | ||
63 | // ')' is for align dangling close bracket | 63 | // ')' is for align dangling close bracket | ||
64 | // ';' is for align `for' parts | 64 | // ';' is for align `for' parts | ||
65 | // ' ' is to add a '()' after `if', `while', `for', ... | 65 | // ' ' is to add a '()' after `if', `while', `for', ... | ||
66 | // TBD <others> | 66 | // TBD <others> | ||
67 | triggerCharacters = "{}()[]<>/:;,#\\?!|&/%.@ '\"=*^"; | 67 | triggerCharacters = "{}()[]<>/:;,#\\?!|&/%.@ '\"=*^"; | ||
68 | 68 | | |||
69 | var debugMode = false; | 69 | var debugMode = true; | ||
70 | 70 | | |||
71 | //BEGIN global variables and functions | 71 | //BEGIN global variables and functions | ||
72 | var gIndentWidth = 4; | 72 | var gIndentWidth = 4; | ||
73 | var gSameLineCommentStartAt = 60; ///< Position for same-line-comments (inline comments) | 73 | var gSameLineCommentStartAt = 60; ///< Position for same-line-comments (inline comments) | ||
74 | var gBraceMap = { | 74 | var gBraceMap = { | ||
75 | '(': ')', ')': '(' | 75 | '(': ')', ')': '(' | ||
76 | , '<': '>', '>': '<' | 76 | , '<': '>', '>': '<' | ||
77 | , '{': '}', '}': '{' | 77 | , '{': '}', '}': '{' | ||
▲ Show 20 Lines • Show All 486 Lines • ▼ Show 20 Line(s) | |||||
564 | * blah | 564 | * blah | ||
565 | * );| | 565 | * );| | ||
566 | * \endcode | 566 | * \endcode | ||
567 | */ | 567 | */ | ||
568 | function tryAfterDanglingSemicolon_ch(line) | 568 | function tryAfterDanglingSemicolon_ch(line) | ||
569 | { | 569 | { | ||
570 | var result = -1; | 570 | var result = -1; | ||
571 | var prevString = document.line(line - 1); | 571 | var prevString = document.line(line - 1); | ||
572 | var r = /^(\s*)(([\)\]}]?\s*)*([\)\]]\s*))?;/.exec(prevString); | 572 | var regex = /^(\s*)(([\)\]}]?\s*)*([\)\]]\s*))?;/; | ||
573 | if (r != null) | 573 | var r = regex.exec(prevString); | ||
574 | if (r !== null && r[0].length > 0) | ||||
574 | { | 575 | { | ||
575 | result = Math.floor(r[1].length / 4) * 4; | 576 | result = Math.floor(r[1].length / 4) * 4; | ||
577 | dbg("tryDanglingSemi234324colonasdd_ch result='"+r[0]+"'"); | ||||
576 | } | 578 | } | ||
577 | else | 579 | else | ||
578 | { | 580 | { | ||
579 | // Does it looks like a template tail? | 581 | // Does it looks like a template tail? | ||
580 | // i.e. smth like this: | 582 | // i.e. smth like this: | ||
581 | // typedef boost::mpl::blah< | 583 | // typedef boost::mpl::blah< | ||
582 | // params | 584 | // params | ||
583 | // > type;| | 585 | // > type;| | ||
584 | r = /^(\s*)([>]+).*;/.exec(prevString); | 586 | r = /^(\s*)([>]+).*;/.exec(prevString); | ||
585 | if (r != null) | 587 | if (r !== null) | ||
586 | result = Math.floor(r[1].length / 4) * 4; | 588 | result = Math.floor(r[1].length / 4) * 4; | ||
589 | dbg("tryDanglingSemicolonasdd_ch result="+result); | ||||
587 | } | 590 | } | ||
588 | if (result != -1) | 591 | if (result != -1) | ||
589 | { | 592 | { | ||
590 | tryToKeepInlineComment(line); | 593 | tryToKeepInlineComment(line); | ||
591 | dbg("tryDanglingSemicolon_ch result="+result); | 594 | dbg("tryDanglingSemicolon_ch result="+result); | ||
592 | } | 595 | } | ||
593 | return result; | 596 | return result; | ||
594 | } | 597 | } | ||
▲ Show 20 Lines • Show All 2223 Lines • Show Last 20 Lines |