diff options
| author | nyamatongwe <devnull@localhost> | 2002-05-18 23:43:39 +0000 | 
|---|---|---|
| committer | nyamatongwe <devnull@localhost> | 2002-05-18 23:43:39 +0000 | 
| commit | 58ce6d598f1d842ee317baf8ed208df33daa46e4 (patch) | |
| tree | b16f38dee996b4cafe7858a7eb6575e7400d69fd /src/LexCPP.cxx | |
| parent | 364812c781a39f1283935f99b0c29f14a7e92b14 (diff) | |
| download | scintilla-mirror-58ce6d598f1d842ee317baf8ed208df33daa46e4.tar.gz | |
Folding implemented for fold comments //{..//} and C# #region..#endregion.
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++; | 
