diff options
Diffstat (limited to 'src/LexCPP.cxx')
| -rw-r--r-- | src/LexCPP.cxx | 36 | 
1 files changed, 36 insertions, 0 deletions
| diff --git a/src/LexCPP.cxx b/src/LexCPP.cxx index 52af4de4c..d625634ed 100644 --- a/src/LexCPP.cxx +++ b/src/LexCPP.cxx @@ -32,6 +32,10 @@ static inline bool IsAWordStart(const int ch) {  	return (ch < 0x80) && (isalnum(ch) || ch == '_');  } +static inline bool IsASpaceOrTab(const int ch) { +	return (ch == ' ') || (ch == '\t'); +} +  static inline bool IsADoxygenChar(const int ch) {  	return (islower(ch) || ch == '$' || ch == '@' ||  		    ch == '\\' || ch == '&' || ch == '<' || @@ -270,6 +274,15 @@ static bool IsStreamCommentStyle(int style) {  		style == SCE_C_COMMENTDOCKEYWORDERROR;  } +static bool MatchString(Accessor &styler, int pos, const char *s) { +	for (int i=0; *s; i++) { +		if (*s != styler.SafeGetCharAt(pos+i)) +			return false; +		s++; +	} +	return true; +} +  static void FoldCppDoc(unsigned int startPos, int length, int initStyle, WordList *[],                              Accessor &styler) {  	bool foldComment = styler.GetPropertyInt("fold.comment") != 0; @@ -297,6 +310,29 @@ static void FoldCppDoc(unsigned int startPos, int length, int initStyle, WordLis  				levelCurrent--;  			}  		} +		if (foldComment && (style == SCE_C_COMMENTLINE)) { +			if ((ch == '/') && (chNext == '/')) { +				char chNext2 = styler.SafeGetCharAt(i + 2); +				if (chNext2 == '{') { +					levelCurrent++; +				} else if (chNext2 == '}') { +					levelCurrent--; +				} +			} +		} +		if (style == SCE_C_PREPROCESSOR) { +			if (ch == '#') { +				unsigned int j=i+1; +				while ((j<endPos) && IsASpaceOrTab(styler.SafeGetCharAt(j))) { +					j++; +				} +				if (MatchString(styler, j, "region")) { +					levelCurrent++; +				} else if (MatchString(styler, j, "endregion")) { +					levelCurrent--; +				} +			} +		}  		if (style == SCE_C_OPERATOR) {  			if (ch == '{') {  				levelCurrent++; | 
