diff options
| -rw-r--r-- | doc/ScintillaHistory.html | 6 | ||||
| -rw-r--r-- | lexers/LexCPP.cxx | 15 | 
2 files changed, 19 insertions, 2 deletions
diff --git a/doc/ScintillaHistory.html b/doc/ScintillaHistory.html index a73ba9def..a646f05cd 100644 --- a/doc/ScintillaHistory.html +++ b/doc/ScintillaHistory.html @@ -494,6 +494,8 @@        </tr><tr>  	<td>Van de Bugger</td>  	<td>Tse Kit Yam</td> +	<td>Morten Brørup</td> +	<td>Alexey Denisov</td>      </tr>      </table>      <p> @@ -527,6 +529,10 @@  	character set explicitly.  	</li>  	<li> +	The C++ lexer can fold on #else and #elif with the fold.cpp.preprocessor.at.else property. +	<a href="http://sourceforge.net/p/scintilla/feature-requests/210/">Bug #210</a>. +	</li> +	<li>  	The HTML lexer no longer treats "<?" inside a string in a script as potentially starting an XML document.  	<a href="http://sourceforge.net/p/scintilla/bugs/767/">Bug #767</a>.  	</li> diff --git a/lexers/LexCPP.cxx b/lexers/LexCPP.cxx index 19b675f59..64387a085 100644 --- a/lexers/LexCPP.cxx +++ b/lexers/LexCPP.cxx @@ -320,6 +320,7 @@ struct OptionsCPP {  	std::string foldExplicitEnd;  	bool foldExplicitAnywhere;  	bool foldPreprocessor; +	bool foldPreprocessorAtElse;  	bool foldCompact;  	bool foldAtElse;  	OptionsCPP() { @@ -341,6 +342,7 @@ struct OptionsCPP {  		foldExplicitEnd = "";  		foldExplicitAnywhere = false;  		foldPreprocessor = false; +		foldPreprocessorAtElse = false;  		foldCompact = false;  		foldAtElse = false;  	} @@ -411,6 +413,9 @@ struct OptionSetCPP : public OptionSet<OptionsCPP> {  		DefineProperty("fold.cpp.explicit.anywhere", &OptionsCPP::foldExplicitAnywhere,  			"Set this property to 1 to enable explicit fold points anywhere, not just in line comments."); +		 +		DefineProperty("fold.cpp.preprocessor.at.else", &OptionsCPP::foldPreprocessorAtElse, +			"This option enables folding on a preprocessor #else or #endif line of an #if statement.");  		DefineProperty("fold.preprocessor", &OptionsCPP::foldPreprocessor,  			"This option enables folding preprocessor directives when using the C++ lexer. " @@ -1349,13 +1354,17 @@ void SCI_METHOD LexerCPP::Fold(Sci_PositionU startPos, Sci_Position length, int  				} else if (styler.Match(j, "end")) {  					levelNext--;  				} +				 +				if (options.foldPreprocessorAtElse && (styler.Match(j, "else") || styler.Match(j, "elif"))) { +					levelMinCurrent--; +				}  			}  		}  		if (options.foldSyntaxBased && (style == SCE_C_OPERATOR)) {  			if (ch == '{' || ch == '[' || ch == '(') {  				// Measure the minimum before a '{' to allow  				// folding on "} else {" -				if (levelMinCurrent > levelNext) { +				if (options.foldAtElse && levelMinCurrent > levelNext) {  					levelMinCurrent = levelNext;  				}  				levelNext++; @@ -1367,7 +1376,9 @@ void SCI_METHOD LexerCPP::Fold(Sci_PositionU startPos, Sci_Position length, int  			visibleChars++;  		if (atEOL || (i == endPos-1)) {  			int levelUse = levelCurrent; -			if (options.foldSyntaxBased && options.foldAtElse) { +			if ((options.foldSyntaxBased && options.foldAtElse) || +				(options.foldPreprocessor && options.foldPreprocessorAtElse) +			) {  				levelUse = levelMinCurrent;  			}  			int lev = levelUse | levelNext << 16;  | 
